您可以使用String类的substring()方法从此String中提取一个子字符串,此方法需要传递所需子字符串的开始和结束索引。
public class Substring {
public static void main(String args[]) {
String str = "Welcome to Nhooo";
String sub = str.substring(10, 25);
System.out.println(sub);
}
}输出结果
Nhooo