This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes how to take hashmap out of linkedhashmap? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to take hashmap out of linkedhashmap?" Watch "how to take hashmap out of linkedhashmap?" New topic
Author

how to take hashmap out of linkedhashmap?

Vinod Vijay
Ranch Hand

Joined: Sep 13, 2011
Posts: 137

Hi, i have a linkedhashmap like


If I call values() method on linkedhashmap like


then it gives following result:-
[{PK_FUNCTION_ID=1, MENU_NAME=GOOGLE}, {PK_FUNCTION_ID=2, MENU_NAME=YAHOO}, {PK_FUNCTION_ID=3, MENU_NAME=REDIFF}]

I want to read only the MENU_NAME and put it into some list. Hashmap is easy, just key value pair. This is again key value pair only in other way but linked. Is there any ready method or way to read MENU_NAME or woraround like to substring by putting check '}' and/or 'MENU_NAME='?

Can you please give me some idea?


Vinod Vijay Nair
Ivan Jozsef Balazs
Rancher

Joined: May 22, 2012
Posts: 867
    
    5
I do not see the exact problem, but this might help.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38424
    
  23
Not sure I understand the problem. If you are sure the menuCache object is a LinkedHashMap, why worry about the linked bit? All that affects is the order you read the Entries, Keys or Values when you iterate the Map. What worries me is that you have a Map<String, Object>. You ought to have a Map with PK_Functions as its “V” type. Then you can write
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to take hashmap out of linkedhashmap?