总结:按照索引substring(2,5);意思是从字符串的索引为2开始(包括)到第6个字符(不包括)的位置的截取部分

package com.s.x;

//substring
public class Wang {
	public static void main(String[] args) {
		String s = "This is my oraginal string";
		String s1 = s.substring(2);// substring ()方法是从索引为2开始截取这个索引以后的所有字符串
		System.out.println(s1);
		String s2 = s.substring(4, 7);// sis
		System.out.println(s2);// 因为This is 之间有空格所以是 s i is
	}
}

  

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案