for里面循环啥意思看不懂

for(Car tempCar:dada){                System.out.print(number+".   ");                if(tempCar instanceof PassengerCar)                    System.out.println(tempCar.getName()+"\t"+tempCar.getRentdaily()+"元/天"+"\t"+tempCar.getBusload()+"人"+"\t");                if(tempCar instanceof Trunk)                    System.out.println(tempCar.getName()+"\t"+tempCar.getRentdaily()+"元/天"+"\t"+"\t"+tempCar.getBurden()+"吨");                if(tempCar instanceof PickUp)                    System.out.println(tempCar.getName()+"\t"+tempCar.getRentdaily()+"元/天"+"\t"+tempCar.getBusload()+"人"+"\t"+tempCar.getBurden()+"吨");                number++;            }

for里面循环啥意思看不懂,求大神解释

慕粉4278631
浏览 1790回答 4
4回答

慕移动7983285

增强for循环,它维护的是一个迭代器,用迭代器遍历集合中的对象。

小子贼帅

foreach 加强for循环  tempCar instanceof PassengerCarinstanceof 这个是验证 左面的对象是不是后面类的实例剩下的就都是 变量 字符串 变量的拼接了。。。没什么难度

安静丶美男子

foreach循环遍历。

Mr丶Gary

遍历数组,如果租的是哪种型号的车,就打印输出每天的价格,载客量是多少人,载货量是多少吨。望采纳,谢谢。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java