-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvaTest.java
More file actions
56 lines (56 loc) · 1.81 KB
/
Copy pathvaTest.java
File metadata and controls
56 lines (56 loc) · 1.81 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
54
55
56
class VarArgs{
static void vaTest(int ... v){
System.out.println("so luong doi so: " + v.length);
System.out.println("noi dung: ");
for(int i=0;i<v.length;i++)
System.out.println(" arg" + i + ":" + v[i] );
System.out.println();
}
public static void main(String args[]){
vaTest(10);
vaTest(1,2,3);
vaTest();
}
}
class VarArgs2{
static void vaTest(String msg, int ... v){
System.out.println(msg + v.length);
System.out.println("noi dung: ");
for(int i=0;i<v.length;i++)
System.out.println(" arg " + i + " " + v[i]);
System.out.println();
}
public static void main(String args[]) {
vaTest("moi doi so vararg: ", 10);
vaTest("ba doi so: ", 1,2,3);
vaTest("khong doi so: ");
}
}
class VarArgs3{
static void vaTest(int ... v){
System.out.println("vaTest(int ...): " + "so luong doi so: " +v.length);
System.out.println("noi dung: ");
for(int i=0;i<v.length;i++)
System.out.println("arg" + i + ": " + v[i]);
System.out.println();
}
static void vaTest(boolean ... v){
System.out.println("vaTest(boolean ...): " + "so luong doi so " + v.length);
System.out.println("noi dung: ");
for(int i=0;i<v.length;i++)
System.out.println("arg " + i + ":" + v[i]);
System.out.println();
}
static void vaTest(String msg, int ... v){
System.out.println("vaTest(String, int ...): " + msg + v.length );
System.out.println("noi dung: ");
for(int i=0;i<v.length;i++)
System.out.println("arg" + i + ":" + v[i]);
System.out.println();
}
public static void main(String args[]) {
vaTest(1,2,3);
vaTest("kiem tra: ",10,20);
vaTest(true,false,false);
}
}