Java substring() 方法
生活随笔
收集整理的這篇文章主要介紹了
Java substring() 方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
substring() 方法返回字符串的子字符串。
語法
public String substring(int beginIndex)或public String substring(int beginIndex, int endIndex)參數
-
beginIndex – 起始索引(包括), 索引從 0 開始。
-
endIndex – 結束索引(不包括)。
返回值
子字符串。
實例
public class RunoobTest {public static void main(String args[]) {String Str = new String("This is text");System.out.print("返回值 :" );System.out.println(Str.substring(4) );System.out.print("返回值 :" );System.out.println(Str.substring(4, 10) );} }以上程序執行結果為:
返回值 : is text 返回值 : is te總結
以上是生活随笔為你收集整理的Java substring() 方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C++二维数组作为函数参数
- 下一篇: Java设计链表(不带头结点的单链表)