[Solved] Convert one object to another using generics [closed]
The error you are getting is because your generic is using improper bounding. Change your method declaration to: public static <T extends IFoo2> T convert(IFoo1 foo1, Class<T> clz) { T foo2 = clz.newInstance(); …. return foo2; } There is another type of bounding you may have been thinking of. I recommend reading this SO question: … Read more