Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started