StringBuffer和StringBuilder常用方法
2015-06-25 16:38
573 查看
增:
append() 会在缓冲区尾部进行数据堆加
(能添加boolean,char,double,float,int,long等不同数据类型,唯独不能添加byte,short型,但它俩会自动类型提升到int型)
==========================================================================================
insert(int index,String str) 往指定位置插入
删:
delete(int start,int end) 不包括end
deleteCharAt(int index) 删除指定位置字符
=========================================================================================
改:
replace(int start,int end,String str)
setCharAt(int index,char ch)
setLength()设置StringBuffer长度
reverse() 把字符串反转
=========================================================================================
查:和String一样,因为StringBuffer最终都是String形式存在
charAt()
indexOf()
lastIndexOf()
subString()
append() 会在缓冲区尾部进行数据堆加
(能添加boolean,char,double,float,int,long等不同数据类型,唯独不能添加byte,short型,但它俩会自动类型提升到int型)
==========================================================================================
insert(int index,String str) 往指定位置插入
删:
delete(int start,int end) 不包括end
deleteCharAt(int index) 删除指定位置字符
=========================================================================================
改:
replace(int start,int end,String str)
setCharAt(int index,char ch)
setLength()设置StringBuffer长度
reverse() 把字符串反转
=========================================================================================
查:和String一样,因为StringBuffer最终都是String形式存在
charAt()
indexOf()
lastIndexOf()
subString()
相关文章推荐
- Android requires compiler compliance level 5.0 or 6.0. Found '1.7' instead的问题解决
- iOS控件之UITextField篇
- 使用NEWID()搭配UniqueIdentifier数据产生全球唯一标识码
- iOS控件之UILbel篇
- iOS学习4_UITableView的使用
- iOS学习4_UITableView的使用
- Ros(fuerte)+rgbdslam_freiburg+installation
- maven build 之 basebuild element set
- UINavigationBar 点儿事&&去掉 NavigationBar 上的分割线
- SpannableString与SpannableStringBuilder
- Unique Paths 算法详解
- Android: Failure [INSTALL_FAILED_DEXOPT] and Failure [INSTALL_FAILED_UID_CHANGED] 解决方案
- iOS 8 Auto Layout界面自动布局系列2-使用Xcode的Interface Builder添加布局约束
- salesforce csv 1000 limitation issue
- [LeetCode] Repeated DNA Sequences
- 仿QQ侧滑效果(swifit)
- unique_ptr使用简介
- IOS本地消息推送(UILocalNotification)
- getContextPath、getServletPath、getRequestURI的区别
- easyui menubutton和menu对齐