基本类型包装类 Integer

常用的操作之一:

A:为什么会有基本类型包装类

将基本数据类型封装成对象的好处在于可以在对象中定义更多的功能方法操作该数据。

B::常用操作

用于基本数据类型与字符串之间的转换

public static void main(String[] args) {
String s = Integer.toBinaryString(60);// 把60转成二进制
System.out.println(s);
System.out.println(Integer.toOctalString(60));// 把60转成8进制
System.out.println(Integer.toHexString(60));// 把60转成16进制
System.out.println(Integer.MAX_VALUE);//int类型最大值
System.out.println(Integer.MIN_VALUE);//int类型最小值
Integer i1 = new Integer(100);
System.out.println(i1);
Integer i2 = new Integer("100");
System.out.println(i2);
}

posted @ 2021-03-31 21:27  一块  阅读(52)  评论(0编辑  收藏  举报