码迷,mamicode.com
首页 > 其他好文 > 详细

字符串

时间:2017-06-11 21:21:08      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:字符串   nbsp   之间   比较   indexof   public   ast   连接字符串   空格   

字符串常用提取方法:

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();

字符串

标签:字符串   nbsp   之间   比较   indexof   public   ast   连接字符串   空格   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!