系統(tǒng)提示i cannot be resolved to a variable的錯誤,但我打出來的程序跟答案一樣啊
package mukewang;
import java.util.Arrays;
public class HelloWorld {
?? ?public static void main(String[] args) {
?? ???????? int[] scores = {89,-23,64,91,779,52,73};
?? ???????? System.out.println("本次考試成績前三名為:");????? ?
?? ???????? HelloWorld hello = new HelloWorld
????? hello.showA(scores);
?? ???? }? ?
?? ???? //定義方法完成成績排序并輸出前三名的功能
?? ???? public void showA(int[] scores){
?? ???????? Arrays.sort(scores);
?? ???????? int num = 0;
?? ???????? for(int i = scores.length-1;i >= 0 && num < 3;i--);
?? ???????? if (scores[i] > 100 || scores[i] < 0){
?? ?????????? continue;
?? ???? }
?? ???? num++;
?? ???? if(num > 3){
?? ???????? break;
?? ???? }
?? ???? System.out.println(scores[i]);
}
}
();
?? ??
2016-05-18
你的代碼錯的地方太多了 ,有幾處很明顯的錯誤??HelloWorld?hello?=?new?HelloWorld();
正確的用該是這樣的 :
2016-05-18
知道錯在哪里了?? 打錯符號了 ? 檢查起來真累心……