public class Example4_15{
private int money;
Example4_15(){
money=2000;
}
private int getMoney(){
return money;
}
public static void main(String arg[]){
Example4_15 exa=new Example4_15();
exa.money=3000;
int m=exa.getMoney();
System.out.println("money="+m);
}
}
class Employee{ private double salary=1800;
public void setSalary(double salary){
if(salary>1800&&salary<=6000){
this.salary=salary; }
}
public double getSalary(){
return salary; }
}
public class Example4_16{
public static void main(String arg[]){
Employee zhang=new Employee();
Employee wang=new Employee();
zhang.setSalary(100);
System.out.println("zhang的薪水:"+zhang.getSalary());
wang.setSalary(3888);
System.out.println("wang的薪水:"+wang.getSalary()); }
}