Add an object to an Array of a custom class
arrays, java
Solution
If you want to use an array, you have to keep a counter which contains the number of cars in the garage. Better use an `ArrayList` instead of array:
List<Car> garage = new ArrayList<Car>();
garage.add(redCar);
Problem
Im a beginner to Java and I'm trying to create an array of a custom class. Let say I have a class called car and I want to create an array of cars called Garage. How can I add each car to the garage? This is what I've got: ``` car redCar = new Car("Red"); car Garage [] = new Car [100]; Garage[0] = redCar; ```