Possible Duplicate:
Java Generics
In Eclipse, I am given warnings for using 'rawtypes' and one of it's fixes is to add <?>
. For example:
Class parameter = String.class;
//Eclipse would suggest a fix by converting to the following:
Class<?> parameter = String.class;
What does this <?>
actually mean?
What Does Class Mean? A class — in the context of Java — is a template used to create objects and to define object data types and methods. Classes are categories, and objects are items within each category. All class objects should have the basic class properties.
super T denotes an unknown type that is a supertype of T (or T itself; remember that the supertype relation is reflexive). It is the dual of the bounded wildcards we've been using, where we use ? extends T to denote an unknown type that is a subtype of T .
%% means % character for java. util. Formatter pattern. Since % denotes the beginning of format specifier %% is used to escape % char.
It is a binary OR Operator and copies a bit to the result it exists in either operands. Assume integer variable A holds 60 and variable B holds 13 then. (A | B) will give 61 which is 0011 1101. Whereas || is a logical OR operator and operates on boolean operands.
Class<?>
should be interpreted as a Class
of something, but the something isn't known or cared about.
It's the use of Java generic types. Class
in Java 5 or greater is a parameterized type, so the compiler expects a type parameter. Class<String>
would work in the specific context of your code, but again, in many cases you don't care about the actual type parameter, so you can just use Class<?>
which is telling the compiler that you know Class
expects a type parameter, but you don't care what the parameter is.
Raw types refer to using a generic type without specifying a type parameter. For example, List is a raw type, while List<String> is a parameterized type
See this document for more info: http://www.javapractices.com/topic/TopicAction.do?Id=224
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With