例如:public class Test {
public static void main(String args[]) {
String Str = new String("www.cjavapy.com");
System.out.print("返回值 :" );
System.out.println(Str.substring(4) );
System.out.print("返回值 :" );
System.out.println(Str.substring(4, 11) );
}
}
1、定义和用法
返回一个新的字符串,它是当前字符串的一个子字符串。
2、调用语法String substring(int beginIndex)
String substring(int beginIndex, int endIndex)
3、参数说明
参数描述
beginIndex起始索引(包括), 索引从 0 开始。
endIndex结束索引(不包括)
4、返回值
返回一个新的字符序列,它是此序列的一个子序列。