As part of an assignment I'm supposed to create a bunch of rectangles and put each of those objects within an ArrayList, which is to be initialized in a constructor. I think I've confused myself. Eclipse is telling me that I can't use .add(new_rec) with this object because it is of type (Double, Double). I assume because the ArrayList is simply <Double> this is causing some issue. Aside from that I think I'm misguided somewhere else, but I'm not sure where.
public class WhyWontThisWork {
WhyWontThisWork(Double name, Double rec_name){
Rectangle new_rec = new Rectangle(23.1,43.0);
ArrayList<Double> name = new ArrayList<Double>();
for(int i = 0; i < 10; i++){
name.add(new_rec);
}
}
}
...and the Rectangle class looks like...
public class Rectangle {
private double length;
private double width;
public Rectangle(double length, double width){
this.length = length;
this.width = width;
}
rectangleis not adouble, additionally, you have to give different names forname, they cannot be the samenamealready defined in the scope