如何让 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() 的底部,把这个:
return rephrase;
关于java - 将第一个单词移动到 Java 中的最后一个位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35837245/