The type (generic or generic) is correct.
A simple understanding is the parameterization of types. For example, when we define a class attribute or an instance attribute, we often need to specify specific types, such as Integer, Person and so on.
But if we use generics, we parameterize these concrete types and define them with a generalized "type" T that can represent all types, then this T is the representation of generics.
You can see the motivation of generics in the collection framework. For example, the Map class allows you to add objects of any class to a map, even if the most common situation is to save a specific type of object (such as a string) in a given map.
Because Map.get () is defined as returning an object, it is usually necessary to convert the result of Map.get () to the expected type, as shown in the following code:
【java】? View the plain? Copy? Print?
Map? m? =? New? HashMap(); ?
M.put("key ","value "); ?
String? s? =? (string)? m . get(" key "); ?
To make the program compile, you must cast the result of get () into a String, and hope that the result is really a String. If the data stored in the map is not a string, the above code will throw a ClassCastException.