String s2=s1.replace('-','\0000');---> i dont know what to use for the null chracter (im using windows)
thanks in advance
but i just got the exact same string again "a-b-c", intresting indeed.If no one can think of anything i'll just go with the string tokenizer solution, its not that bad.
Originally posted by luc comeau:
hey hank, it actually has to be two chars not two strings, as the params.
In the current version of Java (1.5) there is a version of replace that can take two Strings (It's actually defined as taking two CharSequences). Time to upgrade?
Originally posted by Matti Poro:
You could use StringBuilder.
"public StringBuilder deleteCharAt(int index)
Removes the char at the specified position in this sequence. This sequence is shortened by one char."
Is that really a handy method? You have to find the position of the offending character, and do that repeatedly. Second, the shifting of the remaining characted will have to be done repeatedly as well, which is inefficient. It it comes done to methods like this, I would say bite the bullet and just write the damn code from scratch: copy the non-dash characters one-at-a-time from the given string to a stringbuilder. done.
I actually am using 1.4.2 becuase i started my software project in it long before 1.5 came out. As for doing this task...which really isnt that big of a deal i figured out that i already wrote a method to handel this function(sort of)...anyways its a long situation to explain but i also had to handel strings such as "a.b-c-d-e.f-g" where a.b and e.f are considered a single element but a "special case", and if the offer was not in alphabetical order it needed to be.So the best route for me was using string tokenizer, add elements to a vector then sort them in place.So everything is good to go now!thanks for all your time and consideration everyone.