返回导航
常用方法
length()方法确定字符串长度
equals( )方法,比较存储在两个字符串对象的内容是否一致 (==:判断两个字符串在内存中的首地址,即判断是否是同一个字符串对象)
字符串比较方法
使用equalsIgnoreCase()方法 //不考虑大小写判断值是否相等
使用toLowerCase()方法//大写字母变成小写
使用toUpperCase( )方法//变成大写
字符串链接
用“+”号链接字符串或者concat()方法连接字符串
字符串提取方法
public int indexOf(int ch) 搜索第一个出现的字符ch(或字符串value)
public int indexOf(String value)
public int lastIndexOf(int ch) 搜索最后一个出现的字符ch(或字符串value)
public int lastIndexOf(String value)
public String substring(int index)提取从位置索引开始的字符串部分
public String substring(int beginindex, int endindex)提取beginindex和endindex之间的字符串部分
public String trim()返回一个前后不含任何空格的调用字符串的副本
字符串拆分方法
split()方法,将一个字符串分割为子字符串,结果作为字符串数组返回//有些符号不能正常使用需要用“//”转义符号转义