返回列表 發帖
  1. public class Ch58
  2. {
  3.     public static void main(String args[])
  4.     {
  5.         Car bus=new Car();
  6.         bus.name="公車";
  7.         bus.wheel=6;
  8.         bus.load=40;

  9.         Car truck=new Car();
  10.         truck.name="卡車";
  11.         truck.wheel=8;
  12.         truck.load=3;
  13.         
  14.         Car taxi=new Car();
  15.         taxi.name="計程車";
  16.         taxi.wheel=4;
  17.         taxi.load=5;
  18.         
  19.         System.out.println(bus.name+"有"+bus.wheel+""+bus.load+"人");
  20.         System.out.println(truck.name+""+truck.wheel+""+truck.load+"");
  21.         System.out.println(taxi.name+""+taxi.wheel+""+taxi.load+"");
  22.     }
  23. }
  24. class Car
  25. {
  26.     String name;
  27.     int wheel;
  28.     int load;

  29.     //建構子 (尚未定義)

  30.     //方法 (尚未定義)
  31. }
複製代碼

TOP

返回列表