Why does this one does not work:
ArrayList<LinkedList<int>>
where this one does:
ArrayList<LinkedList<Integer>>
???
Why does this one does not work:
ArrayList<LinkedList<int>>
where this one does:
ArrayList<LinkedList<Integer>>
???
The argument in the <> must be an object because those classes can only hold objects.
int is a primitive type, where as Integer is simply a wrapper class for that type, so Integer is the one that will work.
Because Java can only use class (and not primitive types) and arrays (also arrays for primitives) for generics (between < and >).
List<Integer> list;
That is also a reason why there are wrapper classes for primitive types:
int -> Integer
boolean -> Boolean
double -> Double
byte -> Byte
etc...