求详解,运行不出结果 public class Base
{
private int a;
public Base(int a)
{
this.a=a;
}
public int getA()
{
return a;
}
public class Sub extends Base
{
private int b;
public Base(int a,int b)
{
super(a);
this.b=b;
}
public int getB()
{
return b;
}
}
public void main(String[] args)
{
Sub sub=new Sub(1,2);
System.out.println("a="+sub.getA()+"b="+sub.getB());
}
}
public static void main(String[] args) {
Sub sub = new Sub(1, 2);
System.out.println("a=" + sub.getA() + "b=" + sub.getB());
}
}
class Sub extends Base {
private int b;
public Sub(int a, int b) {
super(a);
this.b = b;
}