What you want is to override toString()
in your class House
.
class House {
// ... your implementation,
// which I'm guessing it's something like this:
private int number;
private int bottles;
public House(int number, int bottles) {
this.number = number;
this.bottles = bottles;
}
// here you say what you want as output if you print a House, e.g.:
@Override
public String toString() {
return String.valueOf(bottles);
}
}