java - Diamond Operator, Generics, and Compile issues -


i have encountered problem code compiles , runs fine in netbeans, when try compile command line using javac, unchecked warning error , fails. when compile -xlint:unchecked, detailed description of error points issue is.

here fail use generics , problem is: list<string> name = new arraylist();

after adding diamond operator code compiles fine in , out of ide
list<string> name = new arraylist<>();

it seems in first example must use casting, whereas second uses generics.

my question is: bug in ide? netbeans seems catch sorts of other errors, why code compile fine in ide not command line? should obvious new programming, please forgive me if have failed offer question of significance.

information comes close answering question: the java™ tutorials, what point of diamond operator in java 7?(stackoverflow)

i have looked , found bug 250587, not same. also, up-to-date no updates available on netbeans. javac version 1.8.0_91

thanks taking time read this.

not bug,

list<string> name = new arraylist();  //this instantiates raw type of `arraylist` 

and

list<string> name = new arraylist<string>(); // instantiates `arraylist` parametric type `string` 

and

list<string> name = new arraylist<>(); // short-hand since java 7 above 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -