一.substirng

public static void main(String[] args) {
String sendContent = "请查收:www.baidu.com";


//查询字符串最后一个冒号的位置
int index=sendContent.lastIndexOf(":");

//截取
String qian = sendContent.substring(0, index);
String houb = sendContent.substring(index);

//拼接
String all= qian.concat("http").concat(houb);

System.out.println(houb);
System.out.println(qian);
System.out.println(all);
}

 运行结果:

java截取字符串并拼接

二.split

String str = "abc,12,3yy98,0";
String[]  strs=str.split(",");
for(int i=0,len=strs.length;i<len;i++){
    System.out.println(strs[i].toString());
}

 java截取字符串并拼接

 

相关文章:

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