将字符串的部分保存,剩余删去,或只保留指定一段子字符串
生活随笔
收集整理的這篇文章主要介紹了
将字符串的部分保存,剩余删去,或只保留指定一段子字符串
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
substring()
public String substring(int beginIndex) 或 public String substring(int beginIndex, int endIndex)注意: beginIndex -- 起始索引(包括), 索引從 0 開始。 endIndex -- 結束索引(不包括)。 即[ ) 前包后不包例子:
public class Test {public static void main(String args[]) {String Str = new String("1234567890");System.out.println(Str.substring(2) );System.out.println(Str.substring(2,5) );} }輸出結果: 34567890 345總結
以上是生活随笔為你收集整理的将字符串的部分保存,剩余删去,或只保留指定一段子字符串的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JAVA去掉指定字符
- 下一篇: python 接收邮件服务器地址_pyt