Check if 2 list are equal java

The 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.

Syntax

public boolean equals[Object o]

The parameter 'o' represents the object to be compared for equality with this list.

Specified By

equals in interface Collection

Overrides

This method overrides equals in class Object

Returns

The equals method returns a Boolean value 'true' if the specified object is equal to this list else it returns false.

Example 1

import java.util.LinkedList; import java.util.List; public class JavaListEqualsExample1 { public static void main[String[] args] { List list= new LinkedList[]; for [int i=0;i

Chủ Đề