N Tiwa wrote:I am new to generics and wanted to know what is meant by Class<?>. For example if I define a variable say private class<?> test then what is the significance of the wildcard ? there. I did read a little about generics but still bot able to understand what is this notation class<?>.
N Tiwa wrote:I have a class let's say A. This is the basic structure
private final Class<?> test;
As one of those links you posted says, the compiler wants to check that the object "this" is an instance of the type "test". And (I think) the generic type defined in the class heading forces that to be the case, in a way that the compiler can recognize.
You might even be able to get away with "Class BeanData<T>", for that matter. I'm not sure why I think "? extends T" would be necessary, so try the simpler way first.
As I already said, the compiler needs to be able to verify that an instance of class SomeData implements the class of mbeanInterface. It can't do that unless you tell it what that class is. So "?" isn't good enough. I'm still guessing because you're using made-up class names, but from that code all we know is that SomeData implements Data. So presumably you need
don't know what "A" and "MoreData" mean but they don't appear to be useful here. Of course as I said your obfuscation of the class names leaves me to guess at what you're trying to do.
But if that's the only class you have (you said no subclassing) then you might as well do
view plaincopy to clipboardprint?
return new StandardMBean(Data.class, mbeanInterface);
N Tiwa wrote:the constrcutor of this class will be taking class<?> mbeanInterface as parameter and I cannot change that part