字符串右移n位,例如 “hello world” 右移两位 后ldhello wor 要求写一个方法实现此功能,方法的格式是 String moveToRight(String str,int position) str:需要移动的字符串 p:右移的位数
public static String moveToRight(String str,int count){
for (int i = 1; i <= count; i++) {
str = str.substring(str.length() - 1) + str.substring(0, str.length() - 1);
}
return str;
}