Use a catch block that executes if the array size is


Write an application that prompts the user to enter a number to use as an array size, and then attempt to declare an array using the entered size. If the array is created successfully, display an appropriate message. Java generates a NegativeArraySizeException if you attempt to create an array with a negative size, and it creates a NumberFormatException if you attempt to create an array using a nonnumeric value for the size. Use a catch block that executes if the array size is nonnumeric or negative, displaying a message that indicates the array was not created. Save the file as NegativeArray.java.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Use a catch block that executes if the array size is
Reference No:- TGS02740316

Now Priced at $10 (50% Discount)

Recommended (94%)

Rated (4.6/5)