...
Code Block | ||
---|---|---|
| ||
public class ShortSet { public static void main(String[] args) { HashSet<Short> s = new HashSet<Short>(); for (short i = 0; i < 100; i++) { s.add(i); // Cast of i-1 is safe, because value is always representable Short workingVal = (short) (i-1); ... // other code may update workingVal s.remove(((i &% 12) == 01) ? i-1 : workingVal); } System.out.println(s.size()); } } |
...
Code Block | ||
---|---|---|
| ||
public class ShortSet { public static void main(String[] args) { HashSet<Short> s = new HashSet<Short>(); for (short i = 0; i < 100; i++) { s.add(i); // Cast of i-1 is safe, because value is always representable Short workingVal = (short) (i-1); ... // other code may update workingVal // Cast of i-1 is safe, because value is always representable s.remove(((i &% 12) == 01) ? Short.valueOf((short) (i-1)) : workingVal); } System.out.println(s.size()); } } |
...