Below is the program to compare two different list implementations. When I run this, getting true as a result.
I want to understand the behaviour of this equals() method in this case.
package com.tests;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class ListsTest {
public static void main(String[] args) {
List listA = new ArrayList<>();
List listB = new LinkedList<>();
Object object = new Object();
Integer integer = new Integer(4);
listA.add(object);
listB.add(object);
System.out.println(listA.equals(listB));
}
}