相关代码 |
|
// 例5.5.5 Employee.java import java.io.*; class Employee implements Serializable // 表明该类的对象可以被序列化 { private String name; private double salary; public Employee(String n, double s) { name = n; salary = s; } // 加薪水 public void raiseSalary(double byPercent) { double raise = salary * byPercent / 100; salary += raise; } public String toString() { return getClass().getName()+"["+name+",salary="+salary+"]"; } }
相关资源 |
|