Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueIsEmptyExample2 { public static void main(String[] args) { ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); for (int i = 1; i <= 5; i++) { // Adding items to the tail of this queue queue.add(i); } queue.clear(); if(queue.isEmpty()){ System.out.println("isEmpty() method returns "+queue.isEmpty()); System.out.println("Add some elements because the queue is empty."); } else{ System.out.println("isEmpty() method returns "+queue.isEmpty()); System.out.println("Elements are : "+queue); } } }
Output