Question: Suppose you had to write code to iterate through a String array of student names, outputting each name within the array for every array index.

Suppose you had to write code to iterate through a String array of student names, outputting each name within the array for every array index.

Which of the following would be the more flexible approach?

Group of answer choices

final int MAX = 4;

String [] studentNames = new String [ MAX ];

for (int i = 0; i < studentNames.length ; i++ ) {

System.out.println( studentNames [ i ] );

}

String [] studentNames = new String [4];

for (int i = 0; i < 4; i++ ) {

System.out.println( studentNames[ i ]);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!