标签:src extends ima system end com new sys bsp
import java.util.*;
public class c1
{ public static void main(String args[])
{ cs a=new cs(); //隐式调用
cs b=new cs("hello");//显式调用
c c1=new c("the");
c c2=new c("world!");
}
}
//注意看看有没有public
class c
{ public c()
{ System.out.println("父类无参构造函数");
}
public c(String name)
{ System.out.println("父类有参构造函数"+name);
}
}
class cs extends c
{
public cs()
{ System.out.println("子类无参构造函数");
}
public cs(String name)
{ super(name);//注意有参构造函数必须要先调用父类的
//有参构造函数
System.out.println("子类有参构造函数"+name);
}
}
标签:src extends ima system end com new sys bsp
原文地址:http://www.cnblogs.com/mykonons/p/6512421.html