提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
字符串类的子字符串方法。
public class Main { public static void main(String[] args) /** 来 自 n o w j a v a . c o m **/ { String letters = "abcdefghijklmabcdefghijklm"; // test substring methods System.out.printf("Substring from index 20 to end is \"%s\"\n", letters.substring(20)); System.out.printf("%s \"%s\"\n", "Substring from index 3 up to, but not including 6 is", letters.substring(3, 6)); } }