The loop of the string is shifted to the left and the loop is moved right

directly on the code. Interested can look at it, very interesting :)

package cn.edu.ccit.fangwh;

import org.junit.Test;

public class StringShift {
	public String left(String s,int n){
		n=n%s.length();
		return (s+s).substring(n, n+s.length());
	}
	
	public String right(String s,int n){
		return left(s,s.length()-n%s.length());
	}
	@Test
	public void test(){
		String left=left("asdasdff",1);
		String right=right("asdasdff",1);
		System.out.println(left+"  "+right);
	}
}

结果:

sdasdffa  fasdasdf