Created
November 15, 2010 20:36
-
-
Save ohubaut/700894 to your computer and use it in GitHub Desktop.
Try running this in java, you'll obtain 10 as output (autoboxing trap). Run the same in Groovy 1.7.5 will give you 2 as output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.HashSet; | |
import java.util.Set; | |
public class TestAutoboxing { | |
public static void main(String[] args) { | |
Set<Short> testSet = new HashSet<Short>(); | |
short counter=0; | |
while (counter<10) | |
{ | |
testSet.add(counter); | |
testSet.remove(counter - 1); | |
counter++; | |
} | |
System.out.println(testSet.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will most probably change in 1.8