【发布时间】:2020-07-17 12:53:45
【问题描述】:
那么为什么public static void main(String[] args) 我得到了一个错误。我该怎么做才能解决它?
package linkedList;
public class HackerRank {
public class Solution {
// Complete the aVeryBigSum function below.
public long aVeryBigSum(long[] ar) {
long a=0;
for(int i=0;i<ar.length;i++){
a=ar[i]+a;
}
return a;
}
public static void main(String[] args) { ///why this line is not correct
Solution s= new Solution();
long[] ar= {10000,20000,30000};
System.out.println(s.aVeryBigSum(ar));
}
}
}
【问题讨论】:
-
错误是什么?
-
您在主类
HackerRank中有一个内部类Solution。您的main方法在Solution内部 - 这是不允许的,内部类不能有静态方法。
标签: java eclipse methods static public