Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generics Doubt

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys! Is this declaration perfectly legal? Thanks!

List<Integer> ls1 = new LinkedList();
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi guys! Is this declaration perfectly legal? Thanks!

List<Integer> ls1 = new LinkedList();


Hi Sam,

Yeah that is legal, but with compile time warning. ls1 is typesafe reference variable of List parameterized with Integer and on the right hand
side you are creating non type safe LinkedList;

Assigning unsafe object to typesafe reference variable gives compiler warning.



Regards,
cmbhatt
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic