update record
【1】2020.02.12-21:26
1. improve the content
text
When learning list collection, I see the format of the book written list
List<E> list = new ArrayList<>();
and stated: E represents the Java Generics
Not as a learning generic white, naturally do not know what is generic
right, the book says: For example: elements of the collection to a string type, then E can be modified to String
Well, it is understood (in fact, did not understand)
followed by writing code
List<int> list1 = new ArrayList<>();
List<int> list2 = new LinkedList<>();
The results are not compiled by
is what causes it?
It turned out to be inherited only be the object of a generic Object
int is the basic data types, so can not
So we used packaging it
correct wording:
List<Integer> list1 = new ArrayList<>();
List<Integer> list2 = new LinkedList<>();