Compare commits
11 Commits
wangzehui_
...
main
| Author | SHA1 | Date |
|---|---|---|
|
|
98ada2acf0 | 1 month ago |
|
|
6c7ba0db32 | 1 month ago |
|
|
ac5e67e338 | 1 month ago |
|
|
951ec42af1 | 1 month ago |
|
|
a73c975eb5 | 1 month ago |
|
|
31c60ef88a | 1 month ago |
|
|
c9b23646c6 | 1 month ago |
|
|
a00b6ed5d6 | 1 month ago |
|
|
f2a0ff5107 | 1 month ago |
|
|
7f42507bca | 1 month ago |
|
|
131f53887d | 1 month ago |
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
class Demo{
|
||||
public <T> T fun(T t){ //可以接收任意类型的数据
|
||||
return t; //直接把参数返回
|
||||
}
|
||||
}
|
||||
public class GenericsDemo {
|
||||
public static void main(String[] args) {
|
||||
edu.eurasia.generics.Demo d = new edu.eurasia.generics.Demo(); //实例化Demo对象
|
||||
String str = d.fun("汤姆");//传递字符串
|
||||
int i = d.fun(30); //传递数字,自动装箱
|
||||
System.out.println(str); //输出内容
|
||||
System.out.println(i); //输出内容
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue