例子4.4

来源:互联网 发布:spring mvc json 编辑:程序博客网 时间:2024/05/22 07:07

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("现在所有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());
 }
}

原创粉丝点击