- public class Test1 {
- /*一个泛型方法,看完以后你有什么感受*/
-
- public <T> T show(T a, T b) {
- System.out.println(a.getClass());
- System.out.println(b.getClass());
- return b;
- }
- public static void main(String[] args) {
- Test1 t1 = new Test1();
- t1.show(123, "123");
- }
-
- /*这样定义泛型还有意义?*/
- }
复制代码
|
|