I'm trying to solve this question:
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
};
basically there are 2 arrays, one for the names and one for the times, array indexes are matching (for example Elena's time is 341), I have to find the fastest runner, so whoever has the smallest time is the fastest.
first I found the smallest value in times array.
for (int i = 0; i < array.length; i++) {
if(times[i] < fastest)
fastest = times[i];
}
but I don't know how to match names array with times array, I tried this but it didn't work
System.out.println(Arrays.asList(names).indexOf(fastest));