我這個(gè)為啥全都輸出出去了
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
因?yàn)槟愕妮敵稣Z句在for循環(huán)里面,所以每次循環(huán)都會(huì)有一次輸出,你吧System.out.println(max);放在下方的}后面就好了