Explanation
1. Generics in Java are pseudo-generics. This method of implementing generics is called type erasure, and generics implemented based on this method are called pseudo-generics.
2. Since Java's generics only play a role in the compilation phase, they play a role in checking when writing code.
When the code runs, there are no generics inside it.
Example
List<String> l1 = new ArrayList<String>(); List<Integer> l2 = new ArrayList<Integer>(); System.out.println(l1.getClass() == l2.getClass()); //true
The result is true, the Class of List
Collections in Java are mainly divided into four categories:
1. List: ordered, repeatable;
2. Queue: ordered and repeatable;
3. Set: non-repeatable;
4. Map: unordered, with unique keys and non-unique values.
The above is the detailed content of What are java pseudo-generics?. For more information, please follow other related articles on the PHP Chinese website!