似乎它是正确的,我只需要帮助找出它为什么给我这个错误。这是提示:
1.创建一个MyStr类
2. 在 MyStr 类中编写一个名为 break() 的方法。break() 方法接受一个字符串作为其参数,并返回最后两个字符在前面的字符串。
以下是输出示例:
MyStr.break(Hello) 返回 loHel
Mystr.break(Active) 返回 veActi
到目前为止,这是我的代码:
public class Main {
public static void main(String[] args) {
MyStr.strBreak("Morse");
MyStr.strBreak("School");
}
}
public class MyStr{
public static void strBreak(String word){
int x = word.length() - 2;
return(word.substring(x) + word.substring(0, x));
}
}