Java ArrayBlockingQueue forEach() MethodThe forEach() method of Java ArrayBlockingQueue class executes the specified action for each element of Iterable till all the elements are processed or the action throws an exception. Syntax:Parameters:action - This is the action to be performed for every element. Specified By:The forEach() method of ArrayBlockingQueue class is specified by forEach() method in interface Iterable<E>. Throws:The forEach() method throws NullPointerException, if the defined action represents null. Example 1Output: [Reema, Rahul, Rita, Ramesh] Printing the queue with the help of foreach loop: Reema Rahul Rita Ramesh Example 2Output: 1.Roll No. = 15cs1029 College = MVN University Name = Reema 2.Roll No. = 15cs1010 College = MVN University Name = Geetanjali 3.Roll No. = 17cs1029 College = MR University Name = Vineet 4.Roll No. = 15cs1011 College = MVN University Name = Himanshu Example 3Output: 1 Lower case = aman Upper case = AMAN 2 Lower case = bhavika Upper case = BHAVIKA Example 4Output: 71018 8000 1178 1190 Max number = 71018 Min number = 1178 Next TopicJava-arrayblockingqueue-iterator-method |
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