黑马程序员技术交流社区

标题: 继承的格式(代码分享) [打印本页]

作者: wuchangfeng    时间: 2015-7-20 07:30
标题: 继承的格式(代码分享)
class Person
{
public void show()
{
  System.out.println("person");
}
}
/*
class School
{
public void show()
{
  System.out.println("school");
}
}
*/
//class Student extends Person,School
class Student extends Person
{
public void method()
{
  System.out.println("method");
}
}
class Coder extends Student
{
}
class ExtendsDemo2
{
public static void main(String[] args)
{
  Person p = new Person();
  p.show();
  System.out.println("------");
  Student s = new Student();
  s.show();
  s.method();
  System.out.println("------");
  Coder c = new Coder();
  c.show();
  c.method();
}
}





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2