java - Unchecked assignment when initializing a list -
this question has answer here:
- java raw type , generics interaction 2 answers
what difference between
list<string> list = new arraylist();
and
list<string> list = new arraylist<>();
?
in first case, ide highlights , says "unchecked assignment", seem behave same.
no difference, java compiler figure out type, better add inferred type argument:
list<string> list = new arraylist<string>();
Comments
Post a Comment