String类的常用方法

public static String spilt()

{

String str="测*试*字*符";

String[] s = str.split("\\*");

for(String s1 : s)

      rs+= s1+" ";

return rs;//结果:测 试 字 符

}

 

public static int indexOf(){

  String s = "abc";

  return s.indexOf("a");//结果为0

}

 

posted on 2019-02-21 16:22  城市小农民  阅读(90)  评论(0编辑  收藏  举报

导航