這段代碼在Eclipse中運(yùn)行有錯(cuò)誤,在網(wǎng)頁中沒錯(cuò)誤,為什么
這段代碼在Eclipse中運(yùn)行有錯(cuò)誤,在網(wǎng)頁中沒錯(cuò)誤,為什么
package com.oracle.chapterSix;
?
//外部類
public class HelloWorld1 {
?
? // 外部類中的靜態(tài)變量score
? private static int score = 84;
?
? // 創(chuàng)建靜態(tài)內(nèi)部類
?public??? static????? class SInner {
????? // 內(nèi)部類中的變量score
????? int score = 91;
?????
??public void show() {
???System.out.println("訪問外部類中的score:" +? HelloWorld1.score????????? );
???System.out.println("訪問內(nèi)部類中的score:" + score);
??}
?}
?// 測試靜態(tài)內(nèi)部類
?public static void main(String[] args) {
??// 直接創(chuàng)建內(nèi)部類的對象
????? SInner si=new SInner();
?????
????? // 調(diào)用show方法
?? si.show();
?}
}
Eclipse報(bào)錯(cuò)如下:
錯(cuò)誤: 在類 com.oracle.chapterSix.HelloWorld1$SInner 中找不到主方法, 請將主方法定義為:
?? public static void main(String[] args)
2017-08-26
沒錯(cuò)啊,怎么會報(bào)錯(cuò)的呢
2017-08-10
沒有main函數(shù)入口,網(wǎng)頁只是模擬的 所以可以