Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentLinkedQueue; public class ConcurrentLinkedQueueRemoveExample2 { public static void main(String[] args) { List list1 = new List("Cake"); List list2 = new List("Pulses"); List list3 = new List("Sugar"); List list4 = new List("Salt"); List list5 = new List("Basmati Rice"); List list6 = new List("Aata"); ConcurrentLinkedQueue
queue = new ConcurrentLinkedQueue
(); queue.add(list1); queue.add(list2); queue.add(list3); queue.add(list4); queue.add(list5); queue.add(list6); for (List xyz:queue){ System.out.println(xyz); } queue.remove(list4); queue.remove(list1); System.out.println("New List : "+queue); } } class List{ String grocery_item; public List(String grocery_item) { this.grocery_item = grocery_item; } public String toString(){ return this.grocery_item; } }
Output