Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class JavaCollectionAddExample4 { public static void main(String[] args) { //throw NullPointerException as it does not allow null elements ConcurrentLinkedQueue
set = new ConcurrentLinkedQueue<>(); //add String values in this collection set.add(12); //passing null element set.add(null); set.add(0); set.add(5); set.add(45); System.out.print("The elements in Collection : "); System.out.println(set); } }
Output