In order for this to work you need to override hashcode and equals on the contents of the list. Contains uses these methods, which by default are based on the memory reference so it will only work for a shallow copy.
More Related Contents:
- get specific data filed from returned object in java
- Java error when I try to create an object with a constructor with a string parameter [closed]
- How do I correctly implement this code segment without getting a logic error? [closed]
- Compare two objects with .equals() and == operator
- Can we instantiate an abstract class?
- Is there a way to instantiate a class by name in Java?
- What is the difference between “Class.forName()” and “Class.forName().newInstance()”?
- Is an array a primitive type or an object (or something else entirely)?
- How do hashCode() and identityHashCode() work at the back end?
- How to compare two java objects [duplicate]
- make arrayList.toArray() return more specific types
- How to initialize an array of objects in Java
- How can I use JavaScript in Java? [closed]
- How can I return the difference between two lists?
- How to make a deep copy of Java ArrayList [duplicate]
- Deep copy of an object array
- Creating an Arraylist of Objects
- Java rules for casting
- How many objects are created due to inheritance in java?
- Java HashMap – deep copy
- What does the ‘new’ keyword actually do in Java, and should I avoid creating new objects?
- How to serialize object to CSV file?
- How many string objects will be created in memory? [duplicate]
- Creation of Objects: Constructors or Static Factory Methods
- How to deep copy an irregular 2D array
- Cannot instantiate the type for class object (Java)
- Duplicating objects in Java
- Finding out if a list of Objects contains something with a specified field value?
- What happens when an object is assigned to another object
- Does rest supports arraylist of objects?