replace() method is for switching characters or character seqeuances. However your example shows switching of strings/regular expresions so there is no point in using it. In this case you should use replaceAll(String regex, String replacement) .You have to be carefull with it, as it will be replace any matching expresion with your replacement string.
String strName = "My name is";
String expression = "is";
String replacement = "is Michael";
String strName2 = strName.replace(expression, replacement); For second question you have to locate first the word of which you wish to change first character and can do something like this
String str = "david";
String str2 = str.replaceFirst( Character.toString(str.charAt(0)), Character.toString(str.charAt(0)).toUpperCase() );
Note please, that String str was in this case declared, where in your case you will have to locate it somehow!
peter_budo
Code tags enforcer
Moderator
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902