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.
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 :