// 将字符串str前n位放在后面,返回新的字符串 public String headToTail(String str,int n){ if(n==0){ System.out.println(str); return str; } else{ System.out.println(str.substring(n, str.length()) + str.substring(0,n)); return str.substring(n, str.length()) + str.substring(0,n); } } // The substring begins at the specified beginIndex and extends to the character at index endIndex - 1.
// Thus the length of the substring is endIndex-beginIndex. // 0 --> n-1 + n -->str.length()