head fist java第五章中 攻击战舰游戏
所有代码按照书上敲完后出现以下问题
提示创建SimpleDotCom对象出现出错 显示
Multiple markers at this line
- No enclosing instance of type SimpleDotComTestDrive is accessible. Must qualify the allocation with an enclosing instance
of type SimpleDotComTestDrive (e.g. x.new A() where x is an instance of SimpleDotComTestDrive).
- Line breakpoint:SimpleDotComTestDrive [line: 8] - main(String[])
解决方法
1、
SimpleDotComTestDrive d = new SimpleDotComTestDrive();
SimpleDotCom dot = d.new SimpleDotCom();
2、把两个类放在不同的java文件