I'm writing two classes to handle simple auctions. I have a class ready and working, which handles the operations for a single auction, and now I'm writing another class like an auction house, to keep track of all the auctions available. When testing the following part of the class:
import java.util.ArrayList;
public class AuctionHouse {
private ArrayList<DutchAuction> huutokaupat;
public AuctionHouse() {
}
public void addAuction(DutchAuction newAuction) {
huutokaupat.add(newAuction);
}
}
inside a main method with following code("kauppa" is a tested and working object-variable):
AuctionHouse talo = new AuctionHouse();
talo.addAuction(kauppa);
I get:
Exception in thread "main" java.lang.NullPointerException at ope.auction.dutch.AuctionHouse.addAuction(AuctionHouse.java:13) at ope.auction.dutch.DutchAuctionTest.main(DutchAuctionTest.java:54)
How can I fix the problem?