I'm trying to make cars of a certain color go from one array to another. For example if I want all red cars to go to be displayed, I throw the red cars into another temporary array and they get displayed on the screen. How would I make this work? Here is my code:
//Where I declare the arrays
Car[] cars = new Car[11];
Car[] tempCarsArray = new Car[100]; //What size should I make this?
for(int y=0; y<cars.length; y++){
if(cars[y].getColor()=="Red"){
tempCarsArray[y] = new Car(cars[y].getColor(), cars[y].getMake());
textView.setText(tempCarsArray[randomNumber].getColor(), tempCarsArray.getMake(), tempCarsArray[y].getModel(), tempCarsArray[y].getDescription());
n = tempCarsArray.length;
}
}