Let's say I have created an array
int[] maxNums = {62, 24, 54, 92, 12, 45, 75, 43, 46, 98, 23, 98};
I know how to print the maximum and its index. Here I have two repeated numbers 98, how do I print the index of the repeated maximum. 98 is both at the index 9 and 11.
int[] maxNums = {62, 24, 54, 92, 12, 45, 75, 43, 46, 98, 23, 98};
int maxmark = 0, index = 0;
for(int i = 0; i < marks.length; i++){
if(marks[i] > maxmark){
maxmark = marks[i];
index = i;
}
}
System.out.println("Maximum mark = " + maxmark + " Index = " + index);