java学习:substring函数用法

String str;

str=str.substring(int beginIndex);截取掉str从首字母起长度为beginIndex的字符串,将剩余字符串赋值给str;
str=str.substring(int beginIndex,int endIndex);截取str中从beginIndex开始至endIndex结束时的字符串,并将其赋值给str;

Java中的substring函数是我们经常使用的一个函数,用来截取当前字符串的子串,定义如下:
public final class String{
public String substring(int beginIndex);
public String substring(int beginIndex, int endIndex);
}

猜你喜欢

转载自blog.csdn.net/cxk207017/article/details/78240514