问答详情
源自:12-2 项目问题解析 1

输出的数字总是hashcode

Car car1[] = { new Car(1, "奥迪A6", "500/天", "载人"),

new Car(2, "马自达6", "300/天", "载人"),

new Car(3, "金龙皮卡", "600/天", "载货"),

new Car(4, "雪铁龙251", "400/天", "载人,载货"),

new Car(5, "长城C30", "200/天", "载人") };

System.out.println("您可租车的类型及价格目录表:");

System.out.println("序号" + "\t" + "汽车名称" + "\t" + "租金(元/天)" + "\t" + "容量");

for(int i =0 ;i<car1.length;i++){

System.out.println(" " + (i+1) + "\t" + car1[i]);

}

http://img.mukewang.com/57f399820001642004710172.jpg

提问者:宁敏 2016-10-04 19:59

个回答

  • Preety_boy
    2016-10-04 20:49:24
    已采纳

    for (int i = 0; i < car1.length; i++) {

    System.out.println(" " + (i + 1) + "\t" + car1[i].carName + "\t"+ car1[i].theRent + "\t" + car1[i].capacity);

    }


  • Preety_boy
    2016-10-04 20:50:37

    for (int i = 0; i < car1.length; i++) {

    System.out.println(" " + car1[i].carNum + "\t" + car1[i].carName + "\t"+ car1[i].theRent + "\t" + car1[i].capacity);

    }