wood burning stoves*
The moose likes Java in General and the fly likes splitting and comparing splitted Strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "splitting and comparing splitted Strings" Watch "splitting and comparing splitted Strings" New topic
Author

splitting and comparing splitted Strings

Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Hello,



I am trying to read unique data by removing similar values in array after splitting it but unable to go a head. Please advise

Thanks in anticipation
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2317
    
  49
Do you mean you want to have just one copy of each word ie remove all duplicates?
Farakh khan
Ranch Hand

Joined: Mar 22, 2008
Posts: 732
Thanks Tony Docherty for your favorable reply

Yes exactly I need this
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2317
    
  49
If you don't need to maintain any ordering put all the strings into HashSet, if the order needs to be maintained use a LinkedHashSet.
You will need to trim each of the strings returned from split unless you can guarantee there are no spurious white spaces in the original string you are splitting.
 
jQuery in Action, 2nd edition
 
subject: splitting and comparing splitted Strings