java的String类
2016-07-08 16:02
681 查看
1.字符串的创建
(1)public String()
创建一个空的字符串
(2)public String( String s )
用已有的字符创建新的String
(3)public String ( StringBuffer buf )
用StringBuffer对象创建
(4)public String ( char value[ ] )
用字符数组创建
2.字符串的连接
利用“+”运算符进行连接
3.字符串的比较
(1)boolean equals ( object Obj )
(2)boolean equalsIgnoreCase ( String Str ) 忽略大小写,判断两串是否相等
(3)int compareTo ( String Str ) 当前串大,返回>0;当前串小,返回<0;相等返回0
4.字符串的提取和替换
(1)char charAt ( int index ) 返回指定位置的字符
(2)String substring ( int begin ) 返回从begin位置开始的子字符串
(3)String substring ( int begin, int end ) 返回从begin位置开始到end-1位置的字符串,长度为end - begin
(4)String replace ( char ch1, char ch2 ) 将字符串中的ch1 换成 ch2
(5)String replaceAll ( String regex, String replacement ) 将字符串中的regex换成replacement
(6)String trim () 将当前字符串的前部空格和尾部空格去掉
(7)String toUpperCase () 全部变成大写字母
(8)String toLowerCase () 全部变成小写字母
5.字符串的查找
(1)int indexOf ( int ch )
ch首次出现的位置
(2)int indexOf ( int ch, int start )
ch首次出现的位置>=start
(3)int intdexOf ( String str )
str首次出现的位置
(4)int indexOf ( String str, int start )
str首次出现的位置>=start
(5)int lastIndexOf ( int ch )
ch最后出现的位置
(6)int lastIndexOf ( int ch, int start )
ch最后出现的位置<=start
(7)int lastIndexOf ( String str )
str最后出现的位置
(8)int lastIndexOf ( String str, int start )
str最后出现的位置<=start
(9)boolean startaWith ( String prefix )
判断字符串是否为当前字符串前缀
(10)boolean endsWith (String postfix )
判断字符串是否为当前字符串后缀
(1)public String()
创建一个空的字符串
(2)public String( String s )
用已有的字符创建新的String
(3)public String ( StringBuffer buf )
用StringBuffer对象创建
(4)public String ( char value[ ] )
用字符数组创建
2.字符串的连接
利用“+”运算符进行连接
3.字符串的比较
(1)boolean equals ( object Obj )
(2)boolean equalsIgnoreCase ( String Str ) 忽略大小写,判断两串是否相等
(3)int compareTo ( String Str ) 当前串大,返回>0;当前串小,返回<0;相等返回0
4.字符串的提取和替换
(1)char charAt ( int index ) 返回指定位置的字符
(2)String substring ( int begin ) 返回从begin位置开始的子字符串
(3)String substring ( int begin, int end ) 返回从begin位置开始到end-1位置的字符串,长度为end - begin
(4)String replace ( char ch1, char ch2 ) 将字符串中的ch1 换成 ch2
(5)String replaceAll ( String regex, String replacement ) 将字符串中的regex换成replacement
(6)String trim () 将当前字符串的前部空格和尾部空格去掉
(7)String toUpperCase () 全部变成大写字母
(8)String toLowerCase () 全部变成小写字母
5.字符串的查找
(1)int indexOf ( int ch )
ch首次出现的位置
(2)int indexOf ( int ch, int start )
ch首次出现的位置>=start
(3)int intdexOf ( String str )
str首次出现的位置
(4)int indexOf ( String str, int start )
str首次出现的位置>=start
(5)int lastIndexOf ( int ch )
ch最后出现的位置
(6)int lastIndexOf ( int ch, int start )
ch最后出现的位置<=start
(7)int lastIndexOf ( String str )
str最后出现的位置
(8)int lastIndexOf ( String str, int start )
str最后出现的位置<=start
(9)boolean startaWith ( String prefix )
判断字符串是否为当前字符串前缀
(10)boolean endsWith (String postfix )
判断字符串是否为当前字符串后缀
相关文章推荐
- eclipse Android开发环境配置
- java学习总结(16.06.28)包装类和包装类的常用方法
- Jenkins Publish over SSH,上传文件及执行命令
- 崔希凡-javaWeb-笔记day04-day06(2016年7月8日15:54:16)
- 崔希凡-javaWeb-笔记day04-day06(2016年7月8日15:56:47)
- java实现的线程池
- eclipse下切换svn用户 (换用户登录)
- JAVA 判断空
- java web项目整体异常处理机制
- java线程——Thread类的使用
- java调用存储过程
- java 图片处理
- java自学篇之程序设计基础
- Java io操作,poi导出excel,集合自带排序,日志报告
- SpringMVC
- java 空指针
- Java环境搭建(JDK+MyEclipse+Maven+Resin)
- spark分类训练时因分类标签值太大导致outOfMemery
- java中接口回调与java回调机制
- Java SE基础知识点总结(三)