This method is used to compare two lists. It compares the lists as, both lists should have the same size, and all corresponding pairs of elements in the two lists are equal.
boolean equals(Object o)
Parameters: This function has a single parameter which is object to be compared for equality.
Returns: This method returns True if lists are equal.
Below programs show the implementation of this method.
[10, 15, 20] [100, 200, 300] Not equal
Program 2: Below is the code to show implementation of list.addAll() using Linkedlist.
[10, 15, 20] [10, 15, 20] Equal
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.