A class or interface in a declaration that has one or more type parameters (type parameter), which is a generic type.
Generic classes and generic interfaces are collectively known as generics (generic type).
Each generic defines a set of parameterized types, consisting of the name of the class or interface, followed by an angle bracket (<>) to enclose the actual type parameter list corresponding to the generic form-type parameter.
The original ecological type is like removing all generic information from a type declaration. In fact, the original eco-type list is exactly the same as the interface type list before the Java platform has no generics.
If you do not provide a type parameter, it is still legal to use the original ecological type of the collection type and other generics, but you should not do so. If you use the original ecological type, you lose
All the benefits of generics in terms of security and presentation. Since the original ecological type should not be used, why is Java allowed to use the original ecological type? Because this is for compatibility, because
Before JDK1.5, Java had entered its second decade, and before that, Java had no generics, and for the sake of the previous code, it still worked, prompting Java to still support the original ecosystem
Type.
Although primitive types such as list should not be used in new code, it is still possible to use the parameterized object type to allow the insertion of arbitrary objects, such as List<object>
The difference between the original ecological list type and the list<object> type: Not strictly speaking, the former escapes the generic check, while the latter explicitly tells the compiler that it can hold any type of object.
You can assign an object of type list<string> to a variable of the original list type, but you cannot assign an object of type list<string> to a variable of type list<object>. Because generics
Has its own subtype of the rule,list<string> is a subtype of the original ecological List, not a subtype of the parameterized type list<object>. So using a primitive ecosystem like List
Type, you lose type safety, but if you use a parameterized type such as list<object>, you will not.
23rd: Please do not use the original ecological type in the new code