Re: (Java) Dealing With a Rogue Null Pointer Exception at Runtime

  • From: Jared Wright <wright.jaredm@xxxxxxxxx>
  • To: programmingblind@xxxxxxxxxxxxx
  • Date: Tue, 11 Mar 2008 19:46:48 -0400

Sina Bahram wrote:
"you don't check to see if file is null, and then you try to use it in the next line." The constructor throws the IOException. I know I don't have much in the way of sophistocated error handling for this, but that's not really in the scope of what I'm trying to do. The program will only be run by my professor to check for what he's actually having us work through on this particular project, so I can afford to leave some of those loose ends untied. Thanks for the good reminder of good programming practice though, for sure.

"Also, why numrooms-1?"
To account for the room numbering starting at 1 and the array index starting at 0. I guess I could just have the room numbers start at 0, but I found it was easier for me to keep track of things if I just did it this way. Besides, I'd have to rewrite the text file that has all the info about the cave's layout if I were to change the first room's number to 0.

Thanks for the help in nailing this down. I'm about to start working on it in earnest again for the evening, so we'll see what can be done tonight.

View the list's information and change your settings at

Other related posts: