menu

arrow_back How to add a second array to output to the speakers?

by
1 vote
Good evening!
Not have been able to both arrays,just one.:-(
public class Marathon {


public static String[] printResults(String[] names) {
for (int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}
return names;
}


public static void main(String args[]) {
String[] names = { "Elena", "Thomas", "Hamilton", "Suzie", "Phil", "Matt", "Alex", "Emma", "John", "James", "Jane", "Emily", "Daniel", "Neda", "Aaron", "Kate" };
int[] times= { 341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412, 393, 299, 343, 317, 265 };
System.out.println("+----------+----------+" );
System.out.println("|---NAME---|--RESULT--|" );
System.out.println("+----------+----------+" );
printResults(names);

}
}

5c6aeb1ee4aef576826133.png


Если кто может помочь,то спасибо заранее за помощь и лайк :-)

1 comment

You can still printResults method to add the second argument and check that the number of elements of the first coincided with the second number. Well the same cycle

1 Answer

by
 
Best answer
0 votes
for (int i = 0; i < names.length; i++) {
System.out.println(String.format(" %-11s%s", names[i], times[i]));
}