Why output is -1?
Hello, this is my little program, that reads array "times" and prints the winner name. But the winner index = -1, why?! I'm sorry, if i don't correctly write in English, I'm working on it:) Program will be finalized, I know, that it is not very well written, but I need to solve the problem. Program code: public static void main(String[] args) { String[] names = {"John", "David", "Charlotte", "Sergey", "Rob", "Fill"}; int[] times = {50, 45, 67, 21, 48, 38}; int fasterTime = 0; for(int t : times) { if (t>fasterTime) { fasterTime=t; } else if(t<fasterTime) { fasterTime = fusterTime; } else if(t==fasterTime) { fasterTime=t; } } int indexFasterTime = Arrays.asList(times).indexOf(fasterTime); System.out.println(indexFasterTime); // String nameFaster = names[indexFasterTime]; // System.out.println(nameFaster+" win!");