设为首页 加入收藏

TOP

计算机二级java辅导:构造方法的继承
2014-11-20 00:20:14 来源: 作者: 【 】 浏览:18
Tags:计算机 二级 java 辅导 构造 方法 继承

  构造方法是一种特殊的方法,它的继承规则比较简单,而且与普通方法有较大的区别


  1 无参数构造方法的构造方法示例


  class hasConstructor{


  protected int x=100;


  public void showMsg(){


  System.out.println("this is a method in ancesstor");


  }


  public hasConstructor(){


  System.out.println("this is a constructor in ancestor without parameter");


  }


  public hasConstructor(int ix){


  System.out.println("this is a constructor in ancestor with parameter");


  }


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇计算机二级辅导:java对象排序 下一篇Javaweb应用中自动生成文章html页..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: