Meaningless Drivel is fun!*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 2165
    
  47
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: 2165
    
  47
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: splitting and comparing splitted Strings
 
Similar Threads
MultiDimenaional Array sort
trying to find union/intersection of arrays containing integers
Print String from an Array
How to set value in jtable fields??
java.lang.illegalstate exception