java 学习之string常用方法

一. string的常用方法整理

 String 是基于字符数组 char[] 实现的,String 实现了 Serializable 接口,所以支持序列化和反序列化支持
 String常用方法
substring()
length() 返回字符串长度
isEmpty() 返回字符串是否为空
charAt(int index) 返回字符串中第(index+1)个字符(数组索引)
char[] toCharArray() 转化成字符数组
trim()去掉两端空格
toUpperCase()转化为大写
toLowerCase()转化为小写
String concat(String str) 拼接字符串
String replace(char oldChar, char newChar) 将字符串中的
boolean matches(String regex) 判断字符串是否匹配给定的regex正则表达式
boolean contains(CharSequence s) 判断字符串是否包含字符序列 s
String[] split(String regex, int limit) 按照字符 regex将字符串分成 limit 份
String[] split(String regex) 按照字符 regex 将字符串分段
比较方法
boolean equals(Object anObject); 比较对象
boolean contentEquals(String Buffersb); 与字符串比较内容
boolean contentEquals(Char Sequencecs); 与字符比较内容
boolean equalsIgnoreCase(String anotherString);忽略大小写比较字符串对象
int compareTo(String anotherString); 比较字符串
int compareToIgnoreCase(String str); 忽略大小写比较字符串
boolean regionMatches(int toffset, String other, int ooffset, int len)局部匹配
boolean regionMatches(boolean ignoreCase, int toffset, String other, int ooffset, int len)
public native String intern(); 该方法返回一个字符串对象的内部化引用
string1.concat(string2) 字符串连接





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值