For some reason I cannot get my iteration working. I have two classes, Cars and Garage.
I have Map<Integer, Cars> cars = newHashMap<>();
within the Garage class and I want to iterate through all the Car objects in Map looking for a value of "Ford" and then print it out.
Any help/explanations would be great as very much a newbie.
private String model;
model = "Ford";
public void carMake() {
for (Cars eachCar : cars.values()) {
if (cars.containsValue(model)) {
System.out.println("It is a ford");
}
}
}