Question: Write an application which prompts the user to enter a number to use as the size of the array and then attempts to define an
Write an application which prompts the user to enter a number to use as the size of the array and then attempts to define an array using the entered size. Java generates the InputMismatchException if the user does not give correct type of input (integer in this case) and the NegativeArraySizeException if you attempt to create an array with the negative size.
Write catch blocks to catch these two exceptions and display the message that indicates that the array is not created and the reason why it is not created.
If no exceptions are created, display a message that the array with the given size has been successfully created.
Save the program as DefineArray.java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
