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