• Post Reply Bookmark Topic Watch Topic
  • New Topic

get() method not returning values properly  RSS feed

 
vin Hari
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,
Iam sending you a piece of code please check it out and help me,my question is when i click the submenu item that string iam passing to get()method of HashMap sometimes it gives me the value of that key and ometime it is printing null.what can be done,please help me.

Thanks in advance.
[ September 24, 2007: Message edited by: vin Hari ]
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of three simple reasons it would return null:

1) the equals and hashcode for the key are written incorrectly - you're using Strings, so not likely.
2) your key is null
3) the item doesn't exist in the cache.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
I can think of three simple reasons it would return null:

1) the equals and hashcode for the key are written incorrectly - you're using Strings, so not likely.
2) your key is null
3) the item doesn't exist in the cache.

4) the value for the key is null
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!