I have a simple static method :
public static <U> U findStuff(String id) {
// how can i get the class of type U here ?
Class classObject = ....;
return classObject.newInstance();
}
public static void main(String[] args) {
MyEntity entity = MyClass.<MyEntity>findStuff("abc");
}
I wonder how i can get the class object from the U ?
Currently i have to pass the class around because i dont know the way yet.. so, now im using something like this :
public static <U> U findStuff(Class<U> classObject, String id) {
return classObject.newInstance();
}
public static void main(String[] args) {
MyEntity entity = MyClass.findStuff(MyEntity.class, "abc");
}