-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArgsFuncTest.java
More file actions
53 lines (35 loc) · 1.18 KB
/
Copy pathArgsFuncTest.java
File metadata and controls
53 lines (35 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package FunctionNote;
import java.util.*;
public class ArgsFuncTest {
public static void main(String[] args) {
Integer a=1;
Integer b=2;
ArgsFuncTest.soutInteger(a,b,"asd");
List arrayList=new ArrayList();
}
//可变参数类型在jdk 1.5之后引用 以数组形式进行参数传递
public static<T > void soutInteger(T...args){
List<T> list= Arrays.asList(args);
/* public static <T> List<T> asList(T... a) {
return new ArrayList<>(a);
}*/
list.forEach(alist-> System.out.println(alist.getClass()));
System.out.println(list);
System.out.println(Arrays.toString(args));
/* public static String toString(Object[] a) {
if (a == null)
return "null";
int iMax = a.length - 1;
if (iMax == -1)
return "[]";
StringBuilder b = new StringBuilder();
b.append('[');
for (int i = 0; ; i++) {
b.append(String.valueOf(a[i]));
if (i == iMax)
return b.append(']').toString();
b.append(", ");
}
}*/
}
}