Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that declares an array of numbers. The array should have the following numbers in it 7,8,9,10,11. Do this in the main method.

Write a program that declares an array of numbers. The array should have the following numbers in it 7,8,9,10,11. Do this in the main method. Make a method called printArray. This will return nothing, so it should be a void type method. Then make a for loop that looks like this for(int i=0; i < 10; i++). Iterate through the array of numbers and print out each number with println(). If you do this properly you should get an error when your program runs. You will generate an array index out of bounds exception. You need to add exception handling to your program so that you can catch the index out of bounds exception and a normal exception. When you catch the exception just print you caught it. You also need to have a finally section in your try/catch block.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Neo4j

Authors: Gregory Jordan

1st Edition

1484200225, 9781484200223

More Books

Students also viewed these Databases questions

Question

What are the steps that the EEOC uses once a charge is filed?

Answered: 1 week ago

Question

2. Employees and managers participate in development of the system.

Answered: 1 week ago