|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
我是这样写的:
- public class Father {
- String name = "zhangjun";
- class Child {
- public void introFather() {
- System.out.println(Father.this.name);
- }
- }
- }
- class Test {
- public static void main(String[] args) {
- Child outting = new Father().new Child();
- outting.introFather();
- }
- }
复制代码
但提示:
Father.java:13: 错误: 找不到符号
Child outting = new Father().new Child();
^
符号: 类 Child
位置: 类 Test
- public class Father {
- String name = "zhangjun";
- class Child {
- public void introFather() {
- System.out.println(Father.this.name);
- }
- }
- }
- class Test {
- public static void main(String[] args) {
- Father.Child outting = new Father().new Child(); // 这里的类型应该是 Father.Child
- outting.introFather();
- }
- }
复制代码
|
|