今天跟大家分享我一次实验中使用lastIndexof()和substring()替换字符串中某一段字符串
问题描述:实现字符串尾部替换。
int lastIndexOf(char ch||String s):从字符串结束开始搜索返回字符ch或者字符串s在字符串中首次出现的索引
String substring(int beginIndex,int endIndex):取从beginIndex开始到endIndex结束的字符串(其中index从0计起,截取的最后位置是endIdex-1)
附:int indexOf(char ch||String s):返回字符ch或者字符串s在字符串中首次出现的索引
展示:
public class replacetest {
public static String replaceLast(String src,String olds,String news)</