package com.boxfishedu.test;
/**
* Created by JiangTengfei on 16/4/26.
*/
class Hello {
@Override
public String toString() {
return "Hello{}";
}
}
public class Test<K, V> {
public K getK(K k) {
return k;
}
public <N> N getN(N n) {
return n;
}
public <M> M getM(Class<M> m) throws IllegalAccessException, InstantiationException {
return m.newInstance();
}
public static void main(String[] args) throws InstantiationException, IllegalAccessException {
//new Test<>() 与 new Test() 表现不一样
final Object n = new Test().getN(new Hello());
final Hello n1 = new Test<>().getN(new Hello());
final Object m = new Test().getM(Hello.class);
final Hello m1 = new Test<>().getM(Hello.class);
System.out.println(n1);
}
}
网友评论