我该如何将Jave is the language
转换为Is the language Java
呢?下面是我的代码,但我觉得出现了一些问题。
public class Lab042{
public static final String testsentence = "Java is the language";
public static void main(String [] args) {
String rephrased = rephrase( testsentence);
System.out.println("The sentence:"+testsentence);
System.out.println("was rephrased to:"+rephrased);
}
public static String rephrase(String testsentence) {
int index = testsentence.indexOf (' ');
char c = testsentence.charAt(index+1);
String start = String.valueOf(c).toUpperCase();
start += testsentence.substring(index+2);
start += " ";
String end = testsentence.substring(0,index);
String rephrase = start + end;
}
}
rephrase()
中使用StringBuilder
。 - user180100