import java.util.Arrays;
public class HelloWorld {
//完成 main 方法
public static void main(String[] args) {
int[] scores ={89,-23,64,91,119,52,73};
System.out.println("考试成绩的前三名为");
HelleWorld hello = new HelloWorld();
hello.showTop3(scores);
}
//定义方法完成成绩排序并输出前三名的功能
public void showTop3(int[] scores){
Arrays.sort(scores);
int num =0;
for(int i =scores.length-1 ; i>=0;i--){
if(secores[i]<0 || scores[i]>100){
continue;
}
num++;
if(num >3)
break;
}
System.out.println(score[i]);
}
认真看报错信息可以少浪费一些时间 报错都是符号问题,并且有具体的报错位置
HelloWorld.java:7: error: cannot find symbol hello = new HelloWorld(); ^ symbol: class HelleWorld location: class HelloWorld HelloWorld.java:17: error: cannot find symbol if([i]<0 || scores[i]>100){ ^ symbol: variable secores location: class HelloWorld HelloWorld.java:24: error: cannot find symbol System.out.println([i]); ^ symbol: variable score location: class HelloWorld HelloWorld.java:24: error: cannot find symbol System.out.println(score[i]); ^ symbol: variable i location: class HelloWorld 4 errors
报错为:
HelloWorld.java:7: error: cannot find symbol HelleWorld hello = new HelloWorld(); ^ symbol: class HelleWorld location: class HelloWorld HelloWorld.java:17: error: cannot find symbol if(secores[i]<0 || scores[i]>100){ ^ symbol: variable secores location: class HelloWorld HelloWorld.java:24: error: cannot find symbol System.out.println(score[i]); ^ symbol: variable score location: class HelloWorld HelloWorld.java:24: error: cannot find symbol System.out.println(score[i]); ^ symbol: variable i location: class HelloWorld 4 errors