parseInt
public static int parseInt(String s, int radix)throws NumberFormatException
public static int parseInt(String s) throws NumberFormatException
查阅JDK源码可以发现该函数的作用是把字符串转换成Int类型的整数
输入要求:
字符串不能为空;不能输入一位只包含正负号的字符串;除开第一位,其余位只能是数字
radix是进制数,默认是10,要求大于2且小于36
valueof
public static Integer valueOf(int i)
public static Integer valueOf(String s, int radix) throws NumberFormatException
public static Integer valueOf(String s) throws NumberFormatException
这个函数的作用是把输入字符串、int整型转换成指定进制的Integer类型
intValue
Integer a = new Integer(3);
a.intValue();
public int intValue() {
return value;
}
该函数的作用是把Integer对象转换成int
toBinarySting
返回int的二进制表示
System.out.println(Integer.toBinaryString(-7));
11111111111111111111111111111001
写出Integer类中的toBinaryString()方法