Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionIsEmptyExample2 { public static void main(String[] args) { Collection
collection = new ConcurrentLinkedQueue
(); //returns an exception for null element collection.add(null); //returns true if the queue is empty if(collection.isEmpty()){ System.out.println("Add some elements because the queue is empty."); } else{ System.out.println("Elements are : "+collection); } } }
Output