- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4747 Articles for Java 8

Updated on 14-Sep-2020 09:41:53
EnumerationIterator doesn’t have the option of eliminating elements from the collection, whereas an iterator has this facility. An additional disadvantage of using EnumerationIterator is that the name of methods associated with EnumerationIterator is difficult to remember.ExampleFollowing is an example − Live Demoimport java.util.Vector; import java.util.Enumeration; public class Demo { public static void main(String args[]) { Vector day_name = new Vector(); day_name.add("Tuesday"); day_name.add("Thursday"); day_name.add("Saturday"); day_name.add("Sunday"); Enumeration my_days = day_name.elements(); System.out.println("The values are "); while (my_days.hasMoreElements()) ... Read More 
Updated on 14-Sep-2020 09:39:05
Following is an example to retrieve elements from Collection in Java-ListIterator −Example Live Demoimport java. util.* ; public class Demo { public static void main(String args[]) { Vector my_vect = new Vector(); my_vect.add(56); my_vect.add(78); my_vect.add(98); my_vect.add(34); ListIterator my_iter = my_vect.listIterator(); System.out.println("In forward direction:"); while (my_iter.hasNext()) System.out.print(my_iter.next()+" ") ; System.out.print("In backward direction:") ; while (my_iter.hasPrevious()) System.out.print(my_iter.previous()+" "); } }OutputIn forward direction: 56 78 ... Read More 
Updated on 14-Sep-2020 09:36:16
Following is an example to retrieve elements −Example Live Demoimport java.util.*; public class Demo { public static void main(String args[]) { HashSet my_hs = new HashSet() ; my_hs.add("Joe"); my_hs.add ("Rob"); Iterator my_it = my_hs.iterator(); System.out.println("The elements are : "); while (my_it.hasNext()) System.out.println(my_it.next()); } }OutputThe elements are : Joe RobA class named Demo contains the main function, which defines a HashSet collection. Elements are added to this collection using the ‘add’ function. An iterator is defined, and the ... Read More 
Updated on 14-Sep-2020 09:34:04
The ‘for-each’ loop is used to iterate over a set of elements that is stored in a data structure.Syntaxfor (element e: collection) { System.out.println(e); }ExampleFollowing is an example − Live Demopublic class Demo { public static void main(String[] args) { int[] my_vals = {5, 67, 89, 31, -1, 2, 0}; int sum = 0; for (int number: my_vals) { sum += number; } System.out.println("The sum is " + sum); } }OutputThe sum is 193A class named Demo contains the ... Read More 
Updated on 14-Sep-2020 09:26:40
The array class present in java.lang.reflect package belong to the Java reflection class. The Java Reflection class provides static methods, and these methods can be used to create and access Java arrays in a dynamic manner. This class is final, and this means it can’t be changed or even instantiated. The methods present inside this class can be used with the help of the class name itself.The methods present in java.util.Arrays.class can be used to work with arrays, and the java.lang.reflect.Array class contains methods that help in creating and working with Java arrays in a dynamic manner.The java.lang.reflect.Array class is ... Read More 
Updated on 14-Sep-2020 09:21:29
A semaphore is used to control access to a shared resource when a process is being executed. This is done with the help of a counter. When this counter value is greater than 0, access to share resource is provided. On the other hand, if the value of counter is zero, then access to shared resources is denied. The counter basically keeps a count of the number of permissions it has given to the shared resource. This means, a semaphore provides access to a shared resource for a thread.Semaphores are present in the java.util.concurrent package. The concept of semaphore is ... Read More 
Updated on 14-Sep-2020 09:19:31
Quantifier is a concept that allows the programmer to specify the number of occurrences of a specific type of value in the regular expression. There are different types of quantifiers, some of them include ‘?’ (Reluctant quantifier), ‘+’ (Possessive quantifier). In this post, we will see how reluctant quantifier works.ExampleFollowing is an example − Live Demoimport java.util.regex.Matcher; import java.util.regex.Pattern; public class Demo { public static void main(String[] args) { Pattern my_pattern = Pattern.compile("sam+?"); Matcher my_match = my_pattern.matcher("samp"); while (my_match.find()) System.out.println("The pattern has been found - " + my_match.start() ... Read More 
Updated on 14-Sep-2020 09:16:11
The parent class can hold reference to both the parent and child objects. If a parent class variable holds reference of the child class, and the value is present in both the classes, in general, the reference belongs to the parent class variable. This is due to the run-time polymorphism characteristic in Java.ExampleFollowing is an example − Live Democlass Demo_base { int value = 1000; Demo_base() { System.out.println("This is the base class constructor"); } } class Demo_inherits extends Demo_base { int value = 10; Demo_inherits() { System.out.println("This is the inherited ... Read More 
Updated on 14-Sep-2020 09:13:59
The ‘Stream’ interface in Java, which was introduced in Java 8, is used to manipulate data collections in a declarative fashion. Stream interface can also be used to execute processes in parallel, without making the process too complicated. This means, a sequential stream can be declaratively turned into a parallel stream.A parallel stream can be defined as a stream that splits the data collection elements into multiple streams. Every stream is assigned to a separate chunk and it is associated with a different thread. The work is divided between multiple threads, with the help of multiprocessors. This way, the CPU ... Read More 
Updated on 14-Sep-2020 09:11:24
NavigableMap is an extension of the SortedMap collection framework. It is used to arrange the elements in a uniform fashion. NavigableMap has different methods to iterate over the elements in the Map.ExampleFollowing is an example − Live Demoimport java.util.NavigableMap; import java.util.TreeMap; public class Demo { public static void main(String[] args) { NavigableMap my_map = new TreeMap(); my_map.put("A", 856); my_map.put("M", 349); my_map.put("Z", 567); System.out.printf("The descending set is : %s%n", my_map.descendingKeySet()); System.out.printf("The floor entry is : %s%n", my_map.floorEntry("A")); System.out.printf("The first key ... Read More Advertisements