foreach遍历数组 //write your code here...... max = ary[0]; min = ary[0]; for (int j : ary){ if(max <= j){ max = j;} if(min >= j){ min = j;} } System.out.println(max+" "+min); } } 补充foreach知识点: http://c.biancheng.net/view/750.html