First, the phenomenon of wiping out in the generic type
1. What is the phenomenon of wiping out? See the following example:
Import java.util.ArrayList; 2 3 4 public class Erasetypeequivalence {5 public static void Main (String[]args) {6 class C1 = n EW arraylist<string>(). GetClass (); 7 Class c2 = new arraylist<integer>(). GetClass (); 8 9 SYSTEM.OUT.PRINTLN (C1 = = }11}
The results are as follows:
Actually is true, the first point of contact, each object class, will only create a class class of its type in the Java Virtual machine, to create other objects,
Here, though, the generic parameter type is different, but it is essentially a ArrayList class object, so the two are the same. So is true
In this case, there is the so-called generic erase phenomenon.
Inside the generic, no information about the generic parameters can be obtained. That is, although the object is passed in a different time, but after entering into a generic container, their type information is not, and is considered to be "untyped".
X. Java Generics (ii)