目录
Java基础类:
Integer:整数类:
1、byteValue():取得用byte类型表示的整数
2、Int compareTo(Integer anotherInteger):比较两个整数。相等时返回0,小于返回负数
大于返回整数
3、public static String toUnsignedString(int i, int radix):把i改为redix进制的字符串{redix的范围是[2,64]}
4、public static Integer valueOf(int i):将一个整数转换成Integer类型的对象,即装箱
5、public static Integer valueOf(String s):将一个整数转换成Integer类型的对象,即装箱
6、static int parseInt(String s):将字符串参数解析为带符号的十进制数字
7、static int parseInt(String s,redix):将字符串参数解析为第二个参数指定的基数中的无符号整数(redix 表示s的进制)
8、static Integer valueOf(String s, int radix):将字符串以基数radix的要求转换成整数类型,返回一个Integer对象(redix 表示s的进制)
String:
- 判断方法
- equals(String other):判断字符串于other的值是否相等,相等返回true不同返回false
- equlasgnoreCase(String other):判断字符串值是否相等(忽略大小写)
- startsWith(String prefix)判断字符串是否以prefix开头,是返回true不是返回false
- endsWith(String prefix):判断字符串是否以prefix结尾,是返回true不是返回false
- indeox(String str):判断字符是否包含str,包含返回str的数组下标,如果不包含返回-1
- isEmpty() // 判断字符串是否为空。
- 截取功能
- charAt(int index):返回字符串中的第index个字符
- substring(int beginindex):返回一个新的字符串,包含从beginindex到串尾
- substring(int beginindex,int endindex):返回一个新的字符串,包含beginindex到endindex-1的内容
- boolean endsWith(String prefix) // 测试此字符串是否以指定的子串结束
- String[] split(String regex,int limit) // 根据匹配给定的正则表达式来拆分此字符串
- 修改功能
1、toLowerCase():返回一个新的字符串,将该串中的字母全部改成小写
2、toUpperCase():返回一个新的字符串,将该串中的字母全部改成大写
3、replace(char oldChar,char newChar):返回一个新的字符串,将串中的oldChar替换成newChar
4、trim():返回一个新的字符串,删除原串开头和结尾的空格
5、char[] toCharArray() // 将此字符串转换为一个新的字符数组。
StringBuffer:
- append()——将其他Java类型(八大数据类型)数据转化为字符串后,再追加到StringBuffer对象中
- StringBuffer insert(int index,String str)——StringBuffer对象使用insert方法将参数str指定的字符序列插入参数index指定的位置,并返回当前对象的引用。
- public StringBuffer reverse()——StringBuffer对象使用reserve方法将该对象实体中的字符序列翻转,并返回当前对象的引用
- StringBuffer delete(int startIndex,int endIndex)——delete(int startIndex,int endIndex)从当前StringBuffer对象实体中的字符序列中删除一个子字符序列,并返回当前对象的引用。这里startIndex指定了需删除的第一个字符的下标,而endIndex指定了需删除的最后一个字符下标是endIndex-1,即要删除的子字符序列从startIndex到endIndex-1。deleteCharAt(int index)方法删除当前StringBuffer对象的字符序列中index位置处的一个字符。
- StringBuffer replace(int startIndex,int endIndex,String str)——replace(int startIndex,int endIndex,String str)方法将当前StringBuffer对象的startIndex到endIndex-1的字符序列替换成参数str指定的字符序列,并返回当前StringBuffer对象的引用