例4-4和例4-5和例4-6

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;
  }
 }
 

public class Example4_4{
   public static void main(String args[]){
    Lader.bottom=60;
    Lader laderOne,laderTwo;
    System.out.println("现在所有Lader对象的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("现在所有Lader对象的bottom都是"+Lader.bottom);
    System.out.println("laderOne的above:"+laderOne.getAbove());
    System.out.println("laderTwo的above:"+laderTwo.getAbove());
  }
 }

class Tom{
 final int MAX=100;
 static final int MIN=20;
}


public class Example4_5{
  public static void main(String args[]){
   System.out.println(Tom.MIN);
   Tom cat=new Tom();
   int x=0;
   x=Tom.MIN+cat.MAX;
   System.out.println(x);
 }
}

 

class Computer{
    double x,y;
    static double max(double a,double b){
        return a>b?a:b;
    }
}

class Example4_6{
 public static void main(String args[]){
   double max=Computer.max(12,45);
   System.out.println(max);
  }
}

 


    

posted @ 2013-03-21 16:30  张欣博同学  阅读(120)  评论(0编辑  收藏  举报