Write a short snippet of code that converts the first element of the String[] args array to an integer. It should catch an exception and print out a message if the first element cannot be converted to an integer.

What will be an ideal response?


```
int number;
try {
number = Integer.parseInt(number);
}
catch(NumberFormatException nfe) {
System.out.println("The first argument to the command line"
+ " is not an integer; try again.");
System.exit(0);
}
```

Computer Science & Information Technology

You might also like to view...

A virus can infect a Flash BIOS

Indicate whether the statement is true or false

Computer Science & Information Technology

Explain why the RS232 asynchronous serial interface was probably the worst misfortune to befall early personal computers.

What will be an ideal response?

Computer Science & Information Technology

Grounding ensures that the returning flow of current is properly discharged to the ground. _________________________

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

A tab is a button or area within a group that you click to perform a task.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology