關于最后的練習輸出前三名成績
我開始的思路是定義方法把0-100之外的分數換成0,不知道為什么用 for可以,用foreach就沒法替換了,輸出第一名還是119 ? ?public int[] paixu(int[] scores){ ? ? ?
????for(int score:scores){ ? ? ? ? ? ?
????if (score<0||score>100){ ? ? ? ? ? ?
????score=0; ? ? ? ? ?
??}
} ? ? ? ? ? ?
??Arrays.sort(scores); ? ? ? ? ? ?
???return scores; ? ?
??????}
2018-03-15
foreach 不能對數組進行賦值,貌似只能遍歷數組不能改寫
2018-03-15
是用foreach不能改變遍歷對象的值么?網上有這種說法,不確定…