• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Generics related question  RSS feed

 
saravana kumar L
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all

I have doubt in generics,
List<int> c=new ArrayList<int>();
why we cannot use primitive data type like int,double.

can anyone help?

 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Collections can only hold objects, not primitives like int. You could use the wrapper objects though (List <Integer>).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!