The Java code represents a program that uses a Queue to store a list of colors and then removes an item from the queue. The Queue is implemented using a LinkedList. Let's go through the code step-by-step:
import java.util.LinkedList; import java.util.Queue; public class RemoveItem { public static void main(String[] args) { Queue < String > queue_list = new LinkedList < > (); queue_list.add("Yellow"); queue_list.add("Green"); queue_list.add("Pink"); queue_list.add("Black"); queue_list.add("Blue"); queue_list.add("White"); queue_list.add("Red"); System.out.println("Queue before Removal : " + queue_list); System.out.println("Removed Item is : " + queue_list.remove()); System.out.println("Queue after Removal : " + queue_list); } }
Queue before Removal : [Yellow, Green, Pink, Black, Blue, White, Red] Removed Item is : Yellow Queue after Removal : [Green, Pink, Black, Blue, White, Red]
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions