Results 1 to 4 of 4
Thread: Collections
- 02-16-2010, 02:03 PM #1
Member
- Join Date
- Jan 2010
- Posts
- 90
- Rep Power
- 0
Collections
Hi,
I have this code
<code>
Map<Long, String> childFileMap = new HashMap<Long, String>();
childFileMap.put(new Long(1), "aaaaa");
childFileMap.put(new Long(2), "bbbbbb");
childFileMap.put(new Long(3), "ccccccccc");
Iterator childFileMapIterator = (childFileMap.keySet()).iterator();
while (childFileMapIterator.hasNext()) {
String jmsChildCorrelationId = childFileMapIterator.next().toString();
System.out.println("jmsChildCorrelationId========= =="+ jmsChildCorrelationId);
String childFileName = childFileMap.get(1);
System.out.println("childFileName===========" + childFileName);
}
</code>
I am not able to understand why this System.out.println("childFileName===========" + childFileName); prints null
- 02-16-2010, 02:15 PM #2
Hi,
You have stored as Long object as key but you are trying to retreive with primitive long type.
so retreive like this
String childFileName = childFileMap.get(new Long(1));Ramya:cool:
- 02-16-2010, 02:19 PM #3
Member
- Join Date
- Jan 2010
- Posts
- 90
- Rep Power
- 0
thanks Ramya :)
- 02-16-2010, 02:46 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,385
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
Collections.sort()
By collin389 in forum Advanced JavaReplies: 11Last Post: 12-31-2009, 11:03 AM -
Collections Help
By Dr Gonzo in forum New To JavaReplies: 0Last Post: 12-07-2008, 09:15 PM -
Collections Sort
By senthil_jr in forum Advanced JavaReplies: 2Last Post: 06-04-2008, 08:11 AM -
Collections framework
By yuvi461 in forum New To JavaReplies: 2Last Post: 01-08-2008, 10:46 AM -
Performance Of Collections
By thomasprabu in forum Advanced JavaReplies: 0Last Post: 01-05-2008, 11:17 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks