2) Use the String class' replace/replaceAll methods to replace the comma with another character.
Please post whatever you have got so far, that will help in sorting out problems
Kaustubh G Sharma wrote:Use String.contains() method to find your ',' char
In this case contains is useless. It will only tell you if the string contains a comma, not where it is located. indexOf is much better. But replace, replaceAll and replaceFirst (if you only need to replace the first ,) are better alternatives.
If you want to replace them, you can use the String.replace() method
you should have a look at the String API as there are several useful items on there that you may end up using on a daily basis!
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.
If the character oldChar does not occur in the character sequence represented by this String object, then a reference to this String object is returned. Otherwise, a new String object is created that represents a character sequence identical to the character sequence represented by this String object, except that every occurrence of oldChar is replaced by an occurrence of newChar.
Have a look at this, it will replace commas with a question mark :
This method is usefull if you need to now like a file extension or validate if the user inputed data.
If you need to replace, just user the replace/replaceAll and it will do all the job you need.
If you just need to now if the comma is there you may use the contains()
Please post more than a single smilie. You have already been told off for meaningless posts, in another thread.
Kaustubh G Sharma wrote: