public class Maximum2
1: /*
2: * Copyright (c) 1999-2002, Xiaoping Jia.
3: * All Rights Reserved.
4: */
5:
6: /**
7: * This program prints out the maximun of the two intergers supplied as command-line arguments.
8: * It catches the NumberFormatException that can be cuased by ill-formed interges as arguments.
9: */
10: public class Maximum2 {
11:
12: public static void main(String[] args) {
13: if (args.length >= 2) {
14: try {
15: int i1 = Integer.parseInt(args[0]);
16: int i2 = Integer.parseInt(args[1]);
17: System.out.println("The maximum of " + i1 + " and " + i2 + " is: " +
18: ((i1 >= i2) ? i1 : i2));
19: } catch (NumberFormatException e) {
20: System.out.println("Invalid input value: " + e.getMessage());
21: System.out.println("The input values must be integers.");
22: }
23: } else {
24: System.out.println("Usage: java Maximum integer1 integer2");
25: }
26: }
27:
28: }
29: