输出的数字总是hashcode

来源:12-2 项目问题解析 1

宁敏

2016-10-04 19:59

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

写回答 关注

2回答

  • 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);

    }


    宁敏

    非常感谢!

    2016-10-04 21:43:06

    共 1 条回复 >

  • 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);

    }


Java入门第二季 升级版

课程升级!以终为始告别枯燥,在开发和重构中体会Java面向对象编程的奥妙

530653 学习 · 6091 问题

查看课程

相似问题