代碼問題噗
以下代碼可以在IDEA中運行,但在慕課網網站上就不行。請問為什么呢?
import java.util.Arrays;
public class HellowWorld {
? ? //完成 main 方法
? ? public static void main(String[] args) {
? ? ? ? int [] scores = {89, -23, 64, 91, 119, 52, 73};
? ? ? ? System.out.println("the top three are:");
? ? ? ? HellowWorld hello = new HelloWorld();
? ? ? ? hello.Output(scores);
? ? }
? ? //定義方法完成成績排序并輸出前三名的功能
? ? public void Output(int[] scores){
? ? ? ? Arrays.sort(scores);
? ? ? ? int num = 0;
? ? ? ? for( int i = scores.length -1 ; num < 3 && i > 0; i--) {
? ? ? ? ? ? if (scores[i] < 0 || scores[i] > 100) {
? ? ? ? ? ? ? ? continue;
? ? ? ? ? ? }
? ? ? ? ? ? num++;
? ? ? ? ? ? System.out.println(scores[i]);
? ? ? ? }
? ? }
? ??
}
2018-05-31
?HellowWorld hello = new HelloWorld();
是不是因為這一行Hello后面多了一個w