0
我想为两个类中的每一个创建对象,并将这些对象的引用放置在arrayList中,然后迭代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());