Java List equals() MethodThe equals() method of List interface compares the specified object with this collection for equality. It returns a Boolean value true if both the lists have same elements and are of the same size. SyntaxParametersThe parameter 'o' represents the object to be compared for equality with this list. Specified Byequals in interface Collection<E> OverridesThis method overrides equals in class Object ReturnsThe equals method returns a Boolean value 'true' if the specified object is equal to this list else it returns false. Example 1Test it NowOutput: Both the lists are equal. List : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] List1 : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Example 2Test it NowOutput: Both the lists are unequal. List : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] List1 : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Next TopicJava List |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India