Nature has given us that two ears, two eyes, and but one tongue, to the end that we should hear and see more than we speak
把最后一个单词two首字母大写
package Fengzhaung;
public class testt {
public static String last_two_to_Two(String str) {
String newStr;
char[] ch;
ch = str.toCharArray();
int index_two = str.lastIndexOf("two");
ch[index_two] = Character.toUpperCase(ch[index_two]);
newStr = new String(ch);
return newStr;
}
public static void main(String[] args) {
String string = "Nature has given us that two ears, two eyes, and but one tongue, " +
"to the end that we should hear and see more than we speak";
System.out.println(string);
System.out.println(last_two_to_Two(string));
}
}