Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
standard
Jan 1, 2005
magic

ShinAli posted:

This. A tip to spot these kind of problems right away is using a debugger in Eclipse or NetBeans. They both will display all visible variables and indicate their value, which makes "NullPointerException" easier to deal with on multi statement line of code.

A further tip:
In eclipse there is a button in the breakpoints pane to add breakpoints when exceptions occur.
Add one to java.lang.NullPointerException

Adbot
ADBOT LOVES YOU

standard
Jan 1, 2005
magic

ignorant slut posted:

Quick Java NullPointerException question...
...snip...
Thanks in advance for your time and any help you may give me, it is much appreciated!

Use debug mode and breakpoints in whatever IDE you are running and you should be able to work out any NullPointer. Anyway...


I've not ran your code but after a quick look it looks like you've not instantiated your HashMaps.

HashMap<Integer, Dorm> dorms;
should be
Map<Integer, Dorm> dorms = new HashMap<Integer, Dorm>();

You've done this with the other Maps in other classes as as well.

Anyway I think you've misunderstood what HashMaps are for here. They are like a dictionary, IE store Key Value pairs. From your code, it looks like you don't want to do this as you are just using sequential numbers as keys.

In this instance just use an ArrayList for holding your dorms, floors and students:
List<Dorm> dorms = new ArrayList<Dorm>();

standard fucked around with this message at 21:19 on Sep 6, 2008

standard
Jan 1, 2005
magic
Repeating this because your quoted me before I edited:

Anyway I think you've misunderstood what HashMaps are for here. They are like a dictionary, IE store Key Value pairs. From your code, it looks like you don't want to do this as you are just using sequential numbers as keys.

In this instance just use an ArrayList for holding your dorms, floors and students:
List<Dorm> dorms = new ArrayList<Dorm>();

It looks like you are making a decent stab at this so I don't mind chatting to you on MSN (Sorry I'm from the UK and no one uses AIM) if you have any more questions. I won't do your homework for you mind...

Email me your MSN from my profile if you want.

standard
Jan 1, 2005
magic

duck monster posted:

Anyone have any idea when the website for Hibernate will be back up? Its been down for a bit now, and its a bit frusturating that I need to learn how to use it, but all the documentation is on a website that just says "Down for maintainance. Back up soon" or thereabouts.

:(

The docs are included in the latest distro, so just download that.

standard
Jan 1, 2005
magic
Window -> Preferences -> Java -> Compiler -> Compiler Compliance level.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply