Labs

  1. Write a new Java program. In its main check to see if exactly one argument was passed on the command line and if not, exit with an appropriate message.

Otherwise, convert the argument to an int using the code

int count = Integer.parseInt(args[0]);

and then use a for loop to print the numbers from 1 to the given number.

(Solution: solutions/CountTo.java)


Prev -- Up