你的位置:首页 > 软件开发 > Java > 继承——类、超类、子类

继承——类、超类、子类

发布时间:2016-08-05 05:00:06
http://user.qzone.qq.com/1282179846/blog/1470248763引入一个简单的例子://Employee类import java.util.*;public class Employee { private String name; pr ...

http://user.qzone.qq.com/1282179846/blog/1470248763

引入一个简单的例子:

//Employee类import java.util.*;public class Employee {  private String name;  private double salary;  private Date hireday;  public Employee(String n,double s,int year,int month,int day)  {    name =n;    salary = s;    GregorianCalendar calendar = new GregorianCalendar(year,month-1,day);    hireday = calendar.getTime();  }  public String getName()  {    return name;  }  public double getsalary()  {    return salary;    }  public Date gethireday()  {    return hireday;  }  public void raisesalary(double bypercent)  {    double raise = salary*bypercent/100;    salary = salary + raise;  }  //public static void main(String[] args) {    //Employee[] staff = new Employee[3];    //staff[0]=new Employee("diyige",75000,1987,12,25);    //staff[1]=new Employee("dierge",50000,1989,10,1);    //staff[2]= new Employee("disange",40000,1990,3,15);    //for(Employee e : staff)    //{    //  e.raisesalary(5);    //}    //for(Employee e : staff)    //{    //  System.out.println("name="+e.getName()+",salary="+e.getsalary()+",hireday="+e.gethireday());    //}      //}}

 

海外公司注册、海外银行开户、跨境平台代入驻、VAT、EPR等知识和在线办理:https://www.xlkjsw.com

原标题:继承——类、超类、子类

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录