1, in the Java Virtual machine is not generic, all generic class parameters will be erased, as follows:
Public void int num) {} publicvoidint num) {}
These two methods are the same for the Java compiler and therefore cannot be compiled.
2, the following two kinds of writing are OK, but recommended the latter:
Public extends void Test (list<i> list) {} publicvoidextends fruit> list) {}
3, about <? Extends > and <? Extends >
//< extends t> represents the upper bounds of the type, which indicates that the parameterized type may be a subclass of T or T//< Super t> represents the lower bound of a type, indicating that the parameterized type is a supertype of this type (parent type)List<?extendsfruit> list =NewArraylist<apple>(); //Flist.add (New Fruit ()); Compile errorList.add (NULL); Apple Apple= (Apple) list.get (0); Fruit Item= (Fruit) list.get (0); List<?SuperFruit> List1 =NewArraylist<fruit>(); List1.add (NewFruit ()); List1.add (NewApple ()); List1.add (NULL); Fruit item1= (Fruit) list1.get (0); //Apple Apple = (apple) list1.get (0); compilation error
Some notes on Java generics