[Java] 纯文本查看 复制代码 public class Itheima {
public String twoChar(String str,int i){
String subString = "";
if(i<(str.length()-1)){
subString = str.substring(i, i+2);
}else{
subString = str.substring(0,2);
}
return subString;
}
public static void main(String[] args){
String s = new Itheima().twoChar("helloworld", 8);
System.out.println(s);
}
} |