This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
That was my bailout strategy. I wanted to do it shorter. I still don't get why it doesn't work. result is a legal address of the first Hashmap, right? Sow why can't I "put" anything there? Thanks anyway!
Again, we need to see more code. There must have been some other lines between HashMap result = new HashMap; and result.put("name", new String("The Name")); or you would have gotten a NullPointerException. You need to show us the actual code you're using here, in order to get an explanation. Or if this really is the code you're looking at, then delete your .class file and recompile. If that doesn't work, study your class path carefully and look for a .class or .jar file in another directory which is getting run instead of the class you're trying to execute. One way or another, you're not running the code you show above. [ February 16, 2003: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
Marilyn de Queiroz
Joined: Jul 22, 2000
result is a legal address of the first Hashmap, right?
result is not a legal address until you initialize it. You've declared it, but you have not initialized it. Therefore, you should be getting a NullPointerException, as Jim and Thomas have already pointed out.