Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting an error with a game I created after reading chap 3.  RSS feed

 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings everyone, with some of the material I learned (though I had to research how to do random number generation). I created a mini Craps game (it's a dice game). Unfortunately, even though the program compiles, it refuses to run. Here is the error I'm getting:

lamoubeldum@LamouBeldum:~/JavaPrograms/Projects$ java CrapsTest
Exception in thread "main" java.lang.NullPointerException
at CrapsTest.main(CrapsTest.java:12)
lamoubeldum@LamouBeldum:~/JavaPrograms/Projects$

Here is my code, everything compiles just fine:




Is there anything I'm not seeing, maybe you Java Heroes can shed some light on the situation Thanks!

 
Carey Brown
Bartender
Posts: 2992
46
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This creates an array of references but until you initialize them the references are null;
You'll need something like
 
Naziru Gelajo
Ranch Hand
Posts: 175
1
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Carey Brown wrote:
This creates an array of references but until you initialize them the references are null;
You'll need something like


Excellent, thank you very much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!