Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a program called Initializers.java to practice creating and initializing or setting the values in an int array, and accessing elements in that array in

Create a program called Initializers.java to practice creating and initializing or setting the values in an int array, and accessing elements in that array in main:

Declare and instantiate an int array named array1 having size 10 using the Java array initializer syntax with { } to fill array1 with the even integers 2 through 20. Hint: use just one statement: int[] array1 = { };

Using a for loop, print out the elements in array1 all across one line, separated by single spaces, then print a blank line.

Now ask the user how long to make the array using the Scanner or Keyboard nextInt() method, and assign a new int array of that length to reference variable array1, then fill it with even integers starting with 2, using a for loop; finally, print array1s values, using a for loop as above. Hints: you will have to compute each value that you put into the array in the loop, and you will need to use array1.length() or the size the user types in as the limit in the two for loop conditions.

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

Step: 3

blur-text-image

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

2. Whats involved in listening?

Answered: 1 week ago