外部类为abstract时,出错记录。

错误分析: 
	我想在一个外部类为abstract类型父类A里建一个其的子类内部类B;在外部其他类中是不能调到内部类(子类B)的因为
外部调用抽象类必须实现实例化后,才能调内部类
	报错:A.B cannot be resolved to
a type
Base.Sub3 cannot be resolved to 
a type
	例子:调用内部的情况 
public class A   {
class B{
        int b = 66666;
        public int getNum(){
            return b;
        }
    }
  public B getB(){
        return new B();
    }
    public static void main(String args[]){
        A a = new A();
        B b =  a.getB();
    }    
}
或者这样:

public class A   {
    public class B{
        int b = 66666;
        public int getNum(){
            return b;
    }
    }
  public static void main(String args[]){
        A a = new A();
        B b =  a.new B();
    }
}
              ---外部调用抽象类必须实现实例化后,才能调内部类。原因是内部类可以调外部类的参数,你外部类是抽象的,怎么可能让你通过内部类来调用一个抽象外部类未实现的方法!?     不能!!!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值