public void displayData(String [] names, int []scores, char [] grades){
for (String name : names && char grade : grades)
System.out.println(name + "\t");
System.out.print(grade);
Above is my code. I need to put an and operator in the for loop but the code above is not correct. Please help. I will give additional details if needed.
Assuming all the arrays are parallel (all of the same length, with the value in the grades array at index i being the grade of the student in the names array at index i), you probably could just re-write the loop as:
Also, try to avoid multiple System.out.print statements one after another, as each requires a call to the operating system which slows your application down a bit, because the entire program much stop while the operating system handles your request to print the string. Concatenate (stick together with ‘
+‘) strings where possible, instead.