Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionSizeExample3 { public static void main(String[] args) { Collection
collection = new ConcurrentLinkedQueue
(); //returns true if the queue is empty if(collection.size()==0){ System.out.println("The queue is empty."); } else{ System.out.println("Total elements are : "+collection.size()); } } }
Output