- public class GenericDemo {
-
- public static void main(String[] args) {
- Demo<String> d=new Demo<String>();
- d.show("adsf");
-
- d.print(5);
- d.print("asd");
-
- d.method(5);
- Demo.method(6);
- }
- }
- class Demo<T>{
- public void show(T t){
- System.out.println("show:"+t);
- }
- public <Q> void print(Q q){
- System.out.println("print:"+q);
- }
- public static <W> void method(W t){
- System.out.println("method:"+t);
- }
- }
复制代码
d.method()和Demo.method()有区别吗, |