输出数组中第二个最大的数字

int max,nextMax,temp;
for(int num i : numList) {
if(max == null) {
max = i;
} else {
if(max < i) {
nextMax = max;
max = i;
} else {
if( nextMax == null) {
nextMax = i;
} else ( nextMax < i) {
nextMax = i;
}
}
}
}
注:
int a[] = {1, 2, 3, 4, 5};
下面的代码
for(int i : a){
System.out.println(i);
}
等价于
for(int i=0;i<a.length;i++){
System.out.println(a[i]);
}
原文地址:https://www.cnblogs.com/jobs2/p/3018994.html