substring(int beginIndex, int endIndex)在JDK6与JDK7中的实现方式不一样,理解他们的差异有助于更好的使用它们。为了简单起见,下面所说的substring()指的就是substring(int beginIndex, int endIndex)方法。

1、substring()是做什么的?

  substring(int beginIndex ,int endIndex)方法返回一个子字符串,返回的是从原字符串的beginIndex到endIndex-1之间的内容。

String x = "abcdef";
x = x.substring(1,3);
System.out.println(x);
View Code

相关文章:

  • 2021-05-04
  • 2021-06-29
  • 2021-10-30
  • 2022-12-23
  • 2021-12-21
  • 2022-12-23
  • 2022-12-23
  • 2022-03-01
猜你喜欢
  • 2021-04-14
  • 2021-08-29
  • 2021-07-16
  • 2022-12-23
  • 2021-05-15
  • 2021-07-04
  • 2021-07-14
相关资源
相似解决方案