I keep getting a NullPointerException
for an array of objects I created that hasn't been initialized. But my player class has a default contructor so I assumed it would be fine. Why can't I call an instance method with these objects?
My main code block:
public class Blackjack{
public static void main(String[] args){
Player[] p;
p = new Player[6];
}
}
And here is my player constructor:
public class Player {
private int money;
private int bet;
private int handValue;
// Player Constructor
public Player() {
handValue = 0;
money = 100;
this.bet = 0;
}
}