如何使用Java子串方法?
substring()String类的方法具有两个变体,并返回一个新字符串,该字符串是当前字符串的子字符串。子字符串以指定索引处的字符开头,并延伸到该字符串的末尾,或者直到给定第二个参数的endIndex–1。
示例
import java.io.*;
public class Test {
public static void main(String args[]) {
String Str = new String("Welcome to Nhooo.com");
System.out.print("返回值:" );
System.out.println(Str.substring(10) );
}
}输出结果
返回值: Nhooo.com