如何在它的基类中创建子类对象?

时间:2011-03-27 12:40:10

标签: java

  

可能重复:
  How is it possible to create a sub class object within it's base class ?

class arijit
{
 public static void main(String args[])
 {
  System.out.println("Base class main");
  amit ab=new amit();
  ab.a();
  ab.ma();
 }
 public void ma()
 {
  System.out.println("Base class method");
 }
}

class amit extends arijit
{
 public void a()
 {
  System.out.println("Sub Class method");
  ma();
 }
}

0 个答案:

没有答案