字符串

字符串常用提取方法:

1.public  int  indexof(int  ch)                        搜索第一个出现的

2.public  int  indexof(String   value)          字符ch或字符串value

3.public  int  lastindexof(int   ch)              搜索最后一个出现的

4.public  int  lastindexof(String  value)      字符ch或字符串value

5.public  String  subString(int  index)        提取从位置索引开始的字符串部分

6.public  String  subString(int  beginindex,int  endindex)提取begainindex和endindex之间的字符串部分

7.public  String trim()                              返回一个前后不含任何空格的调用字符串的副本

注意:

       beginindex:字符串的位置从0开始算

       endindex:字符串的位置从1开始算

String提供的操作字符串的方法:

a:获得字符串的长度:length();

b:比较字符串:equals();

c:连接字符串:concat();

d:提取字符串:subString();

e:搜索字符串:indexof();

f:拆分字符串:split();

StringBuffer类提供的方法:

a:转换成String类型:toString();

b:连接字符串:append();

c:插入字符串:insert();

原文地址:https://www.cnblogs.com/yinhua7896/p/6986115.html