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]);
}

相关文章:

  • 2022-02-27
  • 2022-12-23
  • 2021-09-01
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-28
  • 2021-05-22
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案