The Java code represents a program that compares two queues to check if they are equal. The queues are implemented using the LinkedList class from the java.util package. Let's go through the code step-by-step:
import java.util.*; public class CompareTwoQueues { public static void main(String[] args) { Queue <String> queue1 = new LinkedList <>(); Queue <String> queue2 = new LinkedList <>(); // Add elements to the first queue queue1.add("Pink"); queue1.add("Black"); queue1.add("Blue"); // Add elements to the second queue queue2.add("Pink"); queue2.add("Black"); queue2.add("Blue"); queue2.add("White"); // Compare the queues boolean isEqual = queue1.equals(queue2); if (isEqual) { System.out.println("The Queues are Equal."); } else { System.out.println("The Queues are Not Equal."); } } }
The Queues are Not Equal.
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions