Question: Write a method that will declare an array of integers - do not instantiate the array yet. Write a try block that will request the
Write a method that will declare an array of integers do not instantiate the array yet. Write a try block that will request the number of elements in the array from the user and then instantiate the array with that number of elements. Create a catch block that catches the NumberFormatException generated by parseInt when reading the user input the number of elements as a string. Create a second catch block that catches the NegativeArraySizeException generated when the array is instantiated with a negative input value. Write meaningful, appropriate messages to your user in the catch blocks. Write a statement after the catch blocks to display the address of the array. name this method exceptionHandlingDemo
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
