- Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtutorial_20.java
More file actions
Latest commit
24 lines (20 loc) · 709 Bytes
/
Copy pathtutorial_20.java
File metadata and controls
24 lines (20 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
classDriver {
publicstaticvoidmain(String[] args) {
System.out.println("Arguments used: " + args.length);
// handle different amount of arguments
if ( args.length == 1) {
System.out.println("First argument is:" + args[0]);
}
elseif ( args.length == 2 ) {
System.out.println("First argument is:" + args[0]);
System.out.println("First argument is:" + args[1]);
}
else {
System.out.println("Wrong number of arguments");
}
// print all your arguments one after the other
for (Stringarg : args) {
System.out.println(arg);
}
}
}