我這個為啥全都輸出出去了
public static void main(String[] args) {
? ? ? ?
int[] hobbies = { 1,2,3,4,12,33,111 };
? ? ? ?
int max=hobbies[0];
? ? ? ?for(int i=0;i<hobbies.length;i++) {
? ? ? ? if(hobbies[i]>max) {
? ? ? ? max=hobbies[i];
? ? ? ? }
? ? ? ?
? ? ? ? System.out.println(max);
? ? ? ?}
}
2019-10-10
樓上正解
2019-09-25
因為你的輸出語句在for循環里面,所以每次循環都會有一次輸出,你吧System.out.println(max);放在下方的}后面就好了