Can we instantiate an object from generic type at runtime? I've a class:
MyClass<T> implements SomeInterface<T> {
..
public T someMethod() {
return <object of Type T> // Desired!!!
}
..
}
Or let suppose I'm calling this method from some other class where I need an instance of generic type:
TestMayClass {
DesiredClass t = new MyClass<DesiredClass>().someMethod();
// Can I have generics type at run time and construct object from it then return to calling method? Manipulating generic type??
}
: This code's not compiled, it's just imaginary code to have something is similar way.