I expected to get lower, but not really. Although this worked when I tried to use String instead of Item Object. I would like to know why the reasons for this and how to code to get the expected result. Thanks.
EXPECTED ------------------------------ removed object are: 2 same object are: 1 3 add object are: 4 ------------------------------
ACTUAL ------------------------------ removed object are: 1 2 3 same object are: add object are: 1 3 4 ------------------------------
package com.javastudy; import java.util.ArrayList; import java.util.List; public class CollectionCompareToObjects { public static void main(String[] args) { List<Item> before = new ArrayList<Item>(); List<Item> after = new ArrayList<Item>(); before.add(new Item(1L)); before.add(new Item(2L));
source share