You want a Collection<House>
.
Do not use LinkedList<House>
unless you need specific behavior of a linked list. This also goes for ArrayList
. You may want either of these as an implementation, but use the most abstract collection you can.
List
is the order of the houses is importantSet
if you want to enforce only one instance of each type of house (may not apply)
So:
Collection<House> houses = new ArrayList<House>();
public Collection<House> getHouses() {
return houses;
}
public void addHouse(House newHouse) {
houses.add(newHouse);
}
I've chosen an ArrayList
implementation because it is efficient to add new elements to the end of the list. This is also true of LinkedList
, but LinkedList
adds additional overhead that makes it efficient to insert entries into the List
. See the documentation for more information.