为什么找不到符号????
interface AA{
//接口
void f();
}
class BB
{
public void f() {System.out.println("BB");}
public class BC implements AA
{
public void f() {System.out.println("BC");}
public class BD implements AA
{
public void f() {System.out.println("BD");}
}
public AA Newn()
{
return new BD();
}
}
public AA New() //BC 没有对象 就无法创建BD对象 因为他们都是非静态class 必须要有外部类对象才能创建内部类对象
{
return new BC();
}
}
class CC
{
public void f() {System.out.println("CC");}
private static class CA implements AA
{
public void f() {System.out.println("CA");}
private static class CB implements AA
{
public void f() {System.out.println("CB");}
}
}
public static AA New(int i)
{
if (i == 1 && i != 2)
return new CA();
else
return new CA.CB();
}
}
public class lianxi19
{
public static void play(BB a)
{
AA a1 = a.New();
AA a2 = a1.Newn();
AA a3 = CC.New(1);
AA a4 = CC.New(2);
}
public static void main(String[] args)
{
play(new BB());
}
}
/*
lianxi19.java:54: 错误: 找不到符号
AA a2 = a1.Newn();
^
符号: 方法 Newn()
位置: 类型为AA的变量 a1
1 个错误
D:\wendang\linshijava\Nine\ten>
*/