I am trying to access a variable that is stores as part of an object that is in an array. However that array is in an arraylist. How can access that variable? To make it clear, I have a car object that has speed. I placed 4 cars in an array. And that array is duplicated and put in an arraylist.
public int getSpeedOfCarA (int index) {//used to access the variable speed in an array
return garage [index].getSpeed ();
}
Now I was trying this but got stuck.
public int getSpeedOfCarB(int n){
carSpeeds.get(...); //not sure what to use here.
}