包装类描述

一、包装类体系图

Boolean类
在这里插入图片描述
Character类
在这里插入图片描述
Byte(Integer。。。)类
在这里插入图片描述

二、包装类和基本数据类型的转换

jdk5前是手动装箱和拆箱 :

public class WrapperType {
    public static void main(String[] args) {
        //手动装箱
        int n1 = 100;
        Integer integer = new Integer(n1);
        Integer integer1 = Integer.valueOf(n1);//两种方法
        // 手动拆箱
        int i = integer.intValue();

    }
}

jdk5后就可以自动装箱和拆箱

public class WrapperType {
    public static void main(String[] args) {
        int n1 = 200;
        Integer integer = n1;//底层使用的是Integer.valueOf(n1)
        int n3 = integer;//自动拆箱,底层依旧使用的是intvalue()
    }
}

其他包装类方法类似

三、包装类和String类型的转换

以Integer和String为例

1.包装类型转String

public class WrapperType {
    public static void main(String[] args) {
        Integer n1 = 100;
        //方式1
        String str = n1 + "";
        //方式2
        String str1 = n1.toString();
        //方式3
        String str3 = String.valueOf(n1);
    }
}

2.String转包装类型

public class WrapperType {
    public static void main(String[] args) {
       
        String str4 = "1234";
        Integer n2 = Integer.parseInt(str4);//使用到了自动装箱
        Integer n3 = new Integer(str4);//使用到了Integer的构造器第二种方法

    }
}

四、包装类的常用方法

1.Integer的常用方法

public class WrapperWay {
    public static void main(String[] args) {
        System.out.println(Integer.MAX_VALUE);//返回最大值
        System.out.println(Integer.MIN_VALUE);//返回最小值
    }
}

2.Character的常用方法

public class WrapperWay {
    public static void main(String[] args) {

        System.out.println(Character.isDigit('a'));//判断是不是数字
        System.out.println(Character.isLetter('a'));//判断是不是字母
        System.out.println(Character.isUpperCase('a'));//判断是不是大写
        System.out.println(Character.isLowerCase('a'));//判断是不是小写
        System.out.println(Character.isWhitespace('a'));//判断是不是空格
        System.out.println(Character.toUpperCase('a'));//转换成大写
        System.out.println(Character.toLowerCase('A'));//转换成小写

    }
}

总结

提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。

  • 5
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Milisira

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值