Line 15 - I declare a new Horse Arraylist.
Yet in lines 17-19 I add those horses to the static variable from class Hippodrome. How does that work? How do the horses transfer from the static variable to the passed argument ?
public class Hippodrome {
static Hippodrome game;
private List<Horse> horses;
public Hippodrome (List horses){
this.horses = horses;
}
public List<Horse> getHorses() {
return horses;
}
public static void main(String[] args) {
game = new Hippodrome(new ArrayList<Horse>());
game.getHorses().add(new Horse("BlackSabbath", 3, 0));
game.getHorses().add(new Horse("BlueSteel", 3, 0));
game.getHorses().add(new Horse("MagentaMarvel", 3, 0));
}
}