我想用集合装对象 但是为什么遍历不出来对象里的内容?

        System.out.println("欢迎使用嗒嗒租车系统:");
        System.out.println("您是否要租车:y是  否");
        Scanner input = new Scanner (System.in);
        String answer =input.nextLine();
        char answer1 =answer.charAt(0);
        if(answer1 == 'y'){
            System.out.println("您可租车的类型和价目表");
            System.out.println("序号  汽车名称  租金  容量");
            
            Car<String> benz = new Bus ("奔驰","400","1","4");
            Car<String> jangling = new Bus ("江铃","300","1","15");
            Car<String>sanling = new Truck("三菱","700","1","20");
            Car<String> dayun = new Truck ("大运","1000","1","4");
            Car<String> hanma = new Pickup ("悍马","400","1","10","4");
            Test.pushCar().add(benz);
            Test.pushCar().add(jangling );
            Test.pushCar().add(sanling);
            Test.pushCar().add(dayun);
            Test.pushCar().add(hanma);
            Iterator it = pushCar().iterator();
            while(it.hasNext()){
              Object obj = it.next();
              System.out.println(obj.toString());
            }
        }else{
            System.out.println("欢迎您再次光临");
        }


微笑即使悲伤_03178099
浏览 1265回答 1
1回答

这是bug

[5.1.3]实战–介绍
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java