zoukankan      html  css  js  c++  java
  • 继承

    package incheir;

    public class i3 extends i2{
    private String deparetment;
    private String specialiay;
    public i3()
    {
    super("hu",21); //父类的构造函数必须在第一行;
    System.out.println("子类有构造方法!");

    }
    }
    package incheir;

    public class i2 {
    public String name;
    public String sex;
    public int age;
    public i2()
    {
    System.out.println("父类无构造方法!");
    }
    public i2(String n,int a)
    {
    name=n;
    age=a;
    System.out.println("父类有构造方法!");
    }
    public void setName(String name) {
    this.name = name;
    }

    public void setSex(String sex) {
    this.sex = sex;
    }

    public void setAge(int age) {
    this.age = age;
    }

    public String getName() {
    return name;
    }

    public String getSex() {
    return sex;
    }

    public int getAge() {
    return age;
    }
    }
    package incheir;

    public class i1 {
    public static void main(String[] args) {
    i3 s=new i3();
    }
    }
  • 相关阅读:
    三维dem
    geoserver 通过代码实现发布地图服务
    restful发布服务
    php防攻击
    redis主从复制
    redis虚拟内存
    redis 持久化
    lamp源码安装
    mysql优化
    php匿名函数与闭包函数
  • 原文地址:https://www.cnblogs.com/Gazikel/p/13427229.html
Copyright © 2011-2022 走看看