For some reason this function in my project is failing:
public void SetPlayersLineups(HashMap<Integer, Player> _players,
ArrayList<Integer> _lineup, boolean isAwayTeam) {
System.out.println(_players.get(2)); //works properly
System.out.println(_players.get(2).getNumberHits()); //null pointer exception
if (isAwayTeam) {
this.awayLineup = _lineup;
this.awayPlay = _players;
} else {
this.homeLineup = _lineup;
this.homePlay = _players;
}
}
/* from Player class */
public int getNumberHits() {
return this.hits;
}
I have a Player class, with a member get function getNumberHits(). The this.awayPlay and this.homePlay properties are not being set correctly. So I debugged with the System.out.println statements. The first returns a Player instance correctly. But when I call the get function I get a null pointer exception. Any ideas?