wood burning stoves*
The moose likes Java in General and the fly likes Getting a required value from a String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Getting a required value from a String" Watch "Getting a required value from a String" New topic

Getting a required value from a String

sivaprasad pasupulathi
Ranch Hand

Joined: Apr 21, 2009
Posts: 36

This may sound strange but I would like to know if there is a better solution for my question.

I have a String say

String abc = " India = Delhi,USA=Washington,UK=London";

I would like to get the values by specifying the country Name.If I want to get the value for India,I should get the corresponding value.I Don't want to use StringTokenizer.I want to know if there are any function in Java6 which can improve my code reading.

John de Michele

Joined: Mar 09, 2009
Posts: 600

You'll be much better off splitting that String up into a Map. Maps use key, value pairs, and allow very quick searching by keys.

Consider Paul's rocket mass heater.
subject: Getting a required value from a String
Similar Threads
How to get the form parameter in the HTML page?
How to buy scjp1.4 examination voucher in India
Prometric Centre Recommendation
Cameron books query
Extract float value from string