Why do generics in Java work with classes but not with primitive types?

For example, this works fine:

List<Integer> foo = new ArrayList<Integer>();

but this is not allowed:

List<int> bar = new ArrayList<int>();

5 Answers
5

Leave a Reply

Your email address will not be published. Required fields are marked *