Java Vector forEach() Method
The forEach() method of Java Vector class is used to perform the given action for each element of the Iterable until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration if that order is specified.
Following is the declaration of forEach() method:
The forEach() method does not return anything. It only performs the given action for each element.
NullPointerException- This method has thrown an exception if the specified action is null.
Java 1.2 and above
Example 1:Test it Now
1 2 3 4 5
Example 2:Test it Now
White Green Black Pink