Reputation: 26938
Is there any difference between initializing using
HashSet<Integer> s = new HashSet(2)
and
HashSet<Integer> s = new HashSet<Integer>(2)
?
Upvotes: 0
Views: 83
Reputation: 47739
Interestingly, compiling with javac 1.7.0_07:
Compiles with unchecked warning --
HashSet<Integer> s0 = new HashSet(2);
Compiles with no messages --
HashSet<Integer> s1 = new HashSet<>(2);
HashSet<Integer> s2 = new HashSet<Integer>(2);
Upvotes: 1
Reputation: 311008
The only difference is that the first one will give you a compiler warning about the raw type 'HashSet'.
Upvotes: 2