I have a problem with the practice that I am trying to solve. I have three arrays accepted in a method. Names, age and salary. I have to return using string.format which shows salary, name and age
Arrays are the same length, and the corresponding elements in each array are connected. I have to find the smallest salary and use it to get the corresponding name and age of the person.
I can find the smallest salary, but I am confused about how to get the appropriate name and age, which is consistent with this.
Thank you in advance
Edit: if I found the lowest salary through this code, what is the capture function of this index and use this index to get the corresponding elements:
public static String getSmallestSalaryString(String[] names, int[] ages, double[] salaries ) {
double smallSal = Integer.MAX_VALUE;
for(int i = 0; i < salaries.length; i++) {
if(smallSal > salaries[i]) {
smallSal = salaries[i];
}
}