forked from AllenDowney/ThinkJavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMax.java
More file actions
24 lines (20 loc) · 520 Bytes
/
Max.java
File metadata and controls
24 lines (20 loc) · 520 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
import java.util.Arrays;
/**
* Demonstrates command-line arguments.
*/
public class Max {
/**
* Converts args to integers and prints the max.
*/
public static void main(String[] args) {
System.out.println(Arrays.toString(args));
int max = Integer.MIN_VALUE;
for (String arg : args) {
int value = Integer.parseInt(arg);
if (value > max) {
max = value;
}
}
System.out.println("The max is " + max);
}
}