提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从整个字符串中获取子字符串
public class Main { /* 时 代 J a v a 提供 */ public static void main(String args[]){ String name="Hello World"; /*print the substring starting from index 6*/ System.out.println(name.substring(6)); /*print the substring starting from index 0 upto 4 not 5. startIndex is inclusive while endIndex is exclusive. */ System.out.println(name.substring(0,5)); } }