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
Get step-by-step solutions from verified subject matter experts
