1. If the type parameters are not restricted, replace all type parameters in the general type with their boundaries or objects.
Therefore, the generated bytecode only includes ordinary classes, interfaces and methods.
2. Insert type conversion when necessary to maintain type safety.
3. In order to maintain polymorphism in extended generic types, generate bridge methods.
Example
List<String> list1 = new ArrayList<String>(); List<Integer> list2 = new ArrayList<Integer>(); System.out.println(list1.getClass() == list2.getClass()); // 打印 true
Java is mainly used in: 1. web development; 2. Android development; 3. client Development; 4. Web development; 5. Enterprise-level application development; 6. Java big data development; 7. Game development, etc.
The above is the detailed content of How to apply type erasure in java. For more information, please follow other related articles on the PHP Chinese website!