logo Practice-It logo

BJP4 Self-Check 7.13: printElements

Language/Type: Java arrays
Author: Marty Stepp (on 2016/09/08)

Write code that uses a for loop to print each element of an array named data that contains five integers. If the array contains the elements [14, 5, 27, -3, 2598], then your code should produce the following output:

element [0] is 14
element [1] is 5
element [2] is 27
element [3] is -3
element [4] is 2598

Once your code works for the array of size 5, generalize the code so that it works for an array of any length.

Type your solution here:

This problem asks for bare code. Submit a fragment of Java code as described. Do not write any class or method heading around your code; just write the lines of code that will produce the result described.

You must log in before you can solve this problem.

Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.