The Java code defines a class named QueueSize that demonstrates how to use the Queue interface to create and manipulate a queue using the LinkedList implementation. Here's a step-by-step explanation of the code:
import java.util.*; public class QueueSize { public static void main(String[] args) { Queue < String > queue_list = new LinkedList < > (); queue_list.add("Orange"); 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 Elements : " +queue_list ); // Get the size of the queue int size = queue_list.size(); System.out.println("Size of the Queue : " + size); } }
Queue Elements : [Orange, Yellow, Green, Pink, Black, Blue, White, Red] Size of the Queue : 8
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions