Creating a function with Object parameter
I have a main class like this:
public class MainClass() {
public Class<? extends Object> myType;
// This does not work, but thats what I want:
public MainClass(Class<? extends Object> type) {
myType = type;
}
public void myMethod(Object<myType> myParameter) {
// Do stuff
}
}
And some classes extending this class, for example:
public class ChildClass() {
public ChildClass() {
super((Class<? extends Object>) String.class);
// this should be changeable to what ever class then String.class
}
}
How do you create a parent method with a variable class type? The code
myMethod(Object<myType> obj); does not work.
No comments:
Post a Comment