Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueForEachExample4 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); queue.add(null); 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