StringBuffer(str.substring(0,n))截取0-(n-1)之间的字符串
import java.lang.StringBuffer; public class Solution { public String LeftRotateString(String str,int n) { if(str.length()<n){ return ""; } if(str!=null){ StringBuffer stf1=new StringBuffer(str.substring(0,n)); StringBuffer stf2=new StringBuffer(str.substring(n,str.length())); stf1.reverse(); stf2.reverse(); return stf1.append(stf2).reverse().toString(); } return ""; } }