Ok so I need to make an object, modify its values using a Java scanner method, add it to a list, and do this 3 times so I have 3 objects in the list all with different values. I then need to use a for loop to print each object.
Here is my code so far. However every time the for loop outputs to to console, it prints 3 objects.. but their values are all the same (that of the final modification) For the sake of simplicity I won't add my class or method codes unless requested. So stuck on this!!
ArrayList<Car>carList = new ArrayList<Car>();
Car b = new Car(0, 0, 0, 0);
modifyCar(b);
carList.add(b);
modifyCar(b);
carList.add(b);
modifyCar(b);
carList.add(b);
for(Car x: carList)
{
x.print();
}