两个lader对象共享bottom

class Lader{
  double above,height;
   static double bottom;
    void setAbove(double a){
above=a;
 }
  void setBottom(double b){
   bottom=b;
   }
    double getAbove(){
     return above;
}
double getBottom(){
 return bottom;
 }
}
 class Example4_4{
   public static void main(String args[]){
   Lader.bottom=60;
Lader laderOne,laderTwo;
 System.out.println("now all Lader's bottom;"+Lader.bottom);
laderOne=new Lader();
laderTwo=new Lader();
System.out.println("laderOne bottom:"+laderOne.getBottom());
System.out.println("laderTwo bottom:"+laderTwo.getBottom());
laderOne.setAbove(11);
laderTwo.setAbove(22);
laderTwo.setBottom(100);
System.out.println("now all Lader's bottom;"+Lader.bottom);
System.out.println("laderOne above :"+laderOne.getAbove());
System.out.println("laderTwo above :"+laderTwo.getAbove());
}
}

posted on 2013-03-24 16:29  agony·  阅读(152)  评论(0编辑  收藏  举报

导航