Java Vector forEach() MethodThe 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. Syntax:Following is the declaration of forEach() method: Parameter:
Returns:The forEach() method does not return anything. It only performs the given action for each element. Exceptions:NullPointerException- This method has thrown an exception if the specified action is null. Compatibility Version:Java 1.2 and above Example 1:Test it NowOutput: 1 2 3 4 5 Example 2:Test it NowOutput: White Green Black Pink Next TopicJava Vector |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India