I have noticed that below code is completely legal in netbeans:
HashSet<String> hashSet = new HashSet<>();
However eclipse is not happy with that, and I have to initialize it like this:
HashSet<String> hashSet = new HashSet<String>();
// or
HashSet<String> hashSet = new HashSet();
And interestingly netbeans suggests to not specify the type parameter in the initialization part and instead use diamond operator?? I want to know what is the difference between these two approaches. And which one should someone use, so that code can be used in different IDEs without any change.