[問題] 新手 static inner class問題
class MyOuter {
static class MyInner{
public void fooA(){
System.out.println("this is non-static method fooA");
}
public static void fooB(){
System.out.println("this is static method fooB");
}
}
}
public class Test {
public static void main(String args[]) {
MyOuter.MyInner m = new MyOuter.MyInner();
m.fooA();
m.fooB();
MyOuter.MyInner().fooB();
}
}
以上是照書(tiger)上打的 但是compile錯誤
倒數第三行應該是new MyOuter.MyInner().fooB(); 對嗎?
因為書上還特地說不需要透過new來建立相關物件實體
這是我自己認為的啦 不過不太相信自己 所以來版上問問看
感謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.216.47.98
推
03/23 02:04, , 1F
03/23 02:04, 1F
→
03/23 02:05, , 2F
03/23 02:05, 2F
→
03/23 13:46, , 3F
03/23 13:46, 3F