[問題]請問JAVA static及non-static的問題

看板Programming作者時間18年前 (2007/11/21 20:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/2 (看更多)
請問為什麼在mymethod裡面可以用this,但不可以用e 我用eclipse所得到error message是 e cannot be resloved 是因為e是main裡面的區域函式嗎??? 但是non-static不是可以直接存取static嗎??? public class Hello { int a=5; int b=30; public static void main(String[] args) { int a =10; System.out.println(a); Hello e = new Hello(); e.mymethod(3); System.out.println(e); } void mymethod (int a) { System.out.println(a); System.out.println(this.a); System.out.println(e); //為什麼這裡不能用e { int b=9; System.out.println(b); System.out.println(this.b); } System.out.println(b); } } -- ※ Origin: SayYA 資訊站 <bbs.sayya.org> ◆ From: 163.23.216.208
文章代碼(AID): #17H1t_00 (Programming)
文章代碼(AID): #17H1t_00 (Programming)