home *** CD-ROM | disk | FTP | other *** search
- /* Parms.class prints the month and year, which are passed in
- * as command-line arguments
- */
- class Parms {
-
- public static void main (String args[]) {
-
- /*
- * Java, unlike C/C++, does not need argument count (argc)
- */
- if (args.length < 2) {
- System.out.println ("usage: java Parms <month> <year>");
- System.exit (1);
- }
-
- /*
- * Unlike in C/C++, args[0] is the FIRST argument.
- * The application name is not available as an argument
- */
- int month = Integer.valueOf (args[0]).intValue();
- int year = Integer.valueOf (args[1]).intValue();
- if (month < 1 || month > 12) {
- System.out.println ("Month must be between 1 and 12");
- System.exit (1);
- }
- if (year < 1970) {
- System.out.println ("Year must be greater than 1969");
- System.exit (1);
- }
-
- System.out.print ("The month that you entered is ");
- System.out.println (month);
- System.out.print ("The year that you entered is ");
- System.out.println (year);
- }
- }
-