Set<Integer> set = new HashSet<Integer>();
Integer i1 = 45;
Integer i2 = 46;
set.add(i1);
set.add(i1);
set.add(i2); System.out.print(set.size() + " ");
set.remove(i2); System.out.print(set.size() + " ");
i1 = 47;
System.out.print(set.toString());
set.remove(i1); System.out.print(set.size() + " ");
The result of this code is 2,1,1 but my expectation is 2,1,0 Could any one help how does it works?
thanks in advance