A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
How to find the value for a particular key in a Hashmap
Joined: May 12, 2008
Jul 13, 2009 14:32:09
I have a hashmap that contains Strings (keys) and Dates (values).
Sample hashmap is:
If a variable containing "5100" is passed in, I want to get "2009-06-29".
author and iconoclast
Joined: Jul 08, 2003
Jul 13, 2009 14:40:26
So if your map is in variable "map", and "5100" is in variable "key", then result becomes "2009-06-29":
result = map.get(key);
[Jess in Action]
Joined: Jun 09, 2009
Jul 13, 2009 14:53:34
is returning actual Java Date objects, then you need:
Date result = map.get(key);
Otherwise you will get a class cast exception (and if your
is using generics, you would get a compile time exception).
Check out the
I agree. Here's the link:
subject: How to find the value for a particular key in a Hashmap
JMSCI listener problem in JBOSS 4.2.3
Problem starting JBOSS 4.2.3
SSL Handshake in SSO
Get timestamp difference in hours and minutes
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014