Repository navigation
Expand file tree
/
Copy pathVarArgs.java
More file actions
74 lines (59 loc) · 2.15 KB
/
Copy pathVarArgs.java
File metadata and controls
74 lines (59 loc) · 2.15 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package Java_Bootcamp.JavaBasics.Methods;
public class VarArgs {
public static void printInts(int... nums) {
System.out.print("Ints: ");
for (int n : nums) System.out.print(n + " ");
System.out.println();
}
public static void printDoubles(double... nums) {
System.out.print("Doubles: ");
for (double n : nums) System.out.print(n + " ");
System.out.println();
}
public static void printLongs(long... nums) {
System.out.print("Longs: ");
for (long n : nums) System.out.print(n + " ");
System.out.println();
}
public static void printFloats(float... nums) {
System.out.print("Floats: ");
for (float n : nums) System.out.print(n + " ");
System.out.println();
}
public static void printChars(char... chars) {
System.out.print("Chars: ");
for (char c : chars) System.out.print(c + " ");
System.out.println();
}
public static void printBooleans(boolean... bools) {
System.out.print("Booleans: ");
for (boolean b : bools) System.out.print(b + " ");
System.out.println();
}
public static void printBytes(byte... bytes) {
System.out.print("Bytes: ");
for (byte b : bytes) System.out.print(b + " ");
System.out.println();
}
public static void printShorts(short... shorts) {
System.out.print("Shorts: ");
for (short s : shorts) System.out.print(s + " ");
System.out.println();
}
public static void printStrings(String... strs) {
System.out.print("Strings: ");
for (String s : strs) System.out.print(s + " ");
System.out.println();
}
public static void main(String[] args) {
printInts(1, 2, 3, 4);
printDoubles(1.1, 2.2, 3.3);
printLongs(100000L, 200000L);
printFloats(1.0f, 2.5f, 3.5f);
printChars('a', 'b', 'c');
printBooleans(true, false, true);
printBytes((byte) 1, (byte) 2);
printShorts((short) 10, (short) 20);
printStrings("hello", "world");
}
}