我想为 2 个类中的每一个创建对象,并将对这些对象的引用放在 arrayList<> 中,然后遍历 arrayList。
    ArrayList<CarbonFootprint> myCarbon = new ArrayList<CarbonFootprint>();
我该如何实施?我可以不用 ArrayList。
    CarbonFootprint myCarbon = new Car(150332.00);
    System.out.printf("My Car emits %.2f pounds per year\n",
            myCarbon.getCarbonFootprint());