Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueForEachExample1 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); queue.add("Reema"); queue.add("Rahul"); queue.add("Rita"); queue.add("Ramesh"); System.out.println(queue); System.out.println("\nPrinting the queue with the help of foreach loop : "); //foreach() will perform the given action for each element for (String xyz: queue) { System.out.println(xyz); } } }
Output