public class Test<T>{
    static class MyTest{
        public MyTest(int k) {
            System.out.println("MyTest created");
        }
    }
    T obj1, obj2;
    public Test(T t, Class<T> cls) throws Exception {
        obj1 = t; // 1
        obj2 = cls.newInstance(); // 2
    }
    public static void main(String[] args) throws Exception {
        MyTest mt = new MyTest(10);
        Test t = new Test(mt, MyTest.class);
    }
}
Login in to like
Login in to comment