Java 数组最大值下标查找方法
public List
for (int i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
maxIndices.clear();
maxIndices.add(i);
} else if (arr[i] == max) {
maxIndices.add(i);
}
}
return maxIndices;
}
原文地址: https://www.cveoy.top/t/topic/qd9K 著作权归作者所有。请勿转载和采集!