My question is as above. Sorry, it’s probably a duplicate but I couldn’t find an example with the <?> on the end.
Why would you not just use Class as the parameter?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Classis a parameterizable class, hence you can use the syntaxClass<T>whereTis a type. By writingClass<?>, you’re declaring aClassobject which can be of any type (?is a wildcard). TheClasstype is a type that contains meta-information about a class.It’s always good practice to refer to a generic type by specifying his specific type, by using
Class<?>you’re respecting this practice (you’re aware ofClassto be parameterizable) but you’re not restricting your parameter to have a specific type.Reference about Generics and Wildcards: http://docs.oracle.com/javase/tutorial/java/generics/wildcards.html
Reference about
Classobject and reflection (the feature of Java language used to introspect itself): https://www.oracle.com/technetwork/articles/java/javareflection-1536171.html