String类型:{:8_518:}
构造方法:
String(byte[] bytes, int off, int len) :将字节数组从off索引开始的len个字节转换成字符串。
String(StringBuffer buffer):将StringBuffer类型的对象转换成String类型。
常用方法:
char charAt(int index) :返回指定索引处的字符。
boolean contains(CharSequence s) :判断字符串中是否包含指定的子字符串s,包含返回true,不包含返回false。
boolean endsWith(String suffix) :测试此字符串是否以指定的后缀结束。是返回true,不是返回false。
boolean equalsIgnoreCase(String anotherString) :将此 String 与另一个 String 比较,不考虑大小写。
byte[] getBytes() :将字符串转换成字节数组。
int indexOf(int ch) :返回指定字符在此字符串中第一次出现处的索引。
int indexOf(String str) :返回指定子字符串在此字符串中第一次出现处的索引。
int lastIndexOf(int ch) :返回指定字符在此字符串中最后一次出现处的索引。
int lastIndexOf(String str) :返回指定子字符串在此字符串中最右边出现处的索引。
char[] toCharArray() :将此字符串转换为一个新的字符数组。
String substring(int beginIndex):切割字符串,从指定索引一直切割到最后,得到一个子字符串。
String substring(int beginIndex, int endIndex):从 beginIndex索引开始切割,一直切割到endIndex,含头不含尾。
String toUpperCase() :字符串转大写
String toLowerCase() :字符串转小写
replace(CharSequence target, CharSequence replacement) :将指定字符串中的target子串替换成replacement。
String[] split(String regex) :根据给定正则表达式的匹配拆分此字符串。
static String valueOf(int i):将int类型的整数转换成String类型。 (静态方法,直接用类名调用即可)
|
|