集册 Java实例教程 从整个字符串中获取子字符串

从整个字符串中获取子字符串

欢马劈雪     最近更新时间:2020-01-02 10:19:05

446
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
从整个字符串中获取子字符串


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));

 

  }

 

}