Skip to main content

L10 - Runtime Exceptions Lab

Runtime Exceptions Lab Using the lecture slides as a guide,

  1. In a new class, instantiate an array that can hold exactly four integers
  2. Using a for loop, prompt the user for an integer and store the value in the array. Repeat this five times (!).
  3. Run your program and note the error.
  4. Use a try/catch block to handle the particular runtime exception that occurred.
Sample Dialog for Improved Version
Enter a number: 1 
Enter a number: 2 
Enter a number: 3 
Enter a number: 4 
Enter a number: 5 
No more room!!
Your numbers are: 1 2 3 4 Goodbye!