File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Murach's Java Servlets and JSP
this week in the
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
It is sorta covered in the
JavaRanch Style Guide
subject: How to find the value for a particular key in a Hashmap
SSL Handshake in SSO
Problem starting JBOSS 4.2.3
Get timestamp difference in hours and minutes
JMSCI listener problem in JBOSS 4.2.3
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014