Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueIsEmptyExample1 { 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); } //returns true if the queue is empty if(queue.isEmpty()){ System.out.println("Add some elements because the queue is empty."); } else{ System.out.println("Elements are : "+queue); } } }
Output