Reputation: 19
I'm looking at the documentation of JasperReports and I do not understand the return type of the following method:
public java.lang.Class<?> getValueClass()
Upvotes: 0
Views: 963
Reputation: 129557
The method returns a Class
object. The ?
indicates that it can be any type of class. You can read more about wildcards here. These Class
objects are often utilized when you're dealing with reflection.
Upvotes: 3
Reputation: 899
Class<?>
refers to any instance of Class. As compared to Class<? extends Collection>
which would narrow the criteria down to a limited group of classes (those that extend Collection
).
This is particularly important when calling methods like newInstance
. If you have Class<?> a
and call a.newInstance()
you'll get an Object
. if you have Class<? extends Collection>
and call b.newInstance()
you'll get an instance of Collection
.
Upvotes: 1
Reputation: 3288
It just returns an instance of a class. ?
parameter which represents a generic wild card object i.e it is a class of any type.
Upvotes: 0