public class textmu {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String id="0123456789";
String shortId,longId,Id;
shortId=id.substring(1,7);
longId=id.substring(2,4);
Id=id.substring(6);
System.out.println(shortId);
System.out.println(longId);
System.out.println(Id);
}
}
总结:substring(x)是从字符串的的第x个字符截取
substring(x,y)是从x到y前的位置停止
答案:
123456
23
6789