码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 包装类知识点


    包装类

    1.针对八种基本数据类型相应的引用类型-包装类
    基本数据类型 包装类
    boolean Boolean
    char Character
    byte Byte
    short Short
    int Integer
    long Long
    float Float
    double Double

    包装类和基本数据的转换
    演示 包装类和基本数据类型的互相转换,这里以int 和Integer演示
    1.jbk5前的手动装箱和拆箱方式,装箱:基本类型-> 包装类型 ,反之,拆箱
    2.jbk5以后(含jbk5)的自动装箱和拆箱方式
    3.自动装箱底层调用是valueOf方法,比如Integer.valueOf()
    4.其他包装类的用法类似

    public class Integer01 {
    public static void main(String[] args) {
    //演示int <–> Integer 装箱和拆箱
    //jbk5前是手动装箱和拆箱
    //手动装箱 int ->Integer
    int n1 =100;
    Integer integer = new Integer(n1);
    Integer integer1 =Integer.valueOf(n1);

        //手动拆箱
        //Integer ->int
        int i=integer.intValue();
    
        //jdk5后,就可以自动装箱和自动拆箱
        int n2=200;
        //自动装箱
        Integer integer2=n2;//底层使用时Integer.valueOf(n2)
        //自动改拆箱 Integer -> int
        int n3 =integer2;//底层仍然使用的是 intValue()方法;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    }

    Integer类 和Character类的常用方法
    Integer 类Character 有哪些常用的方法
    public class WrapperMethod {
    public static void main(String[] args) {
    System.out.println(Integer.MIN_VALUE);//返回最小值
    System.out.println(Integer.MAX_VALUE);//返回最大值

        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'));//转成小写
        -2147483648
        2147483647
        false
        true
        false
        true
        false
        A
        a
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    }

  • 相关阅读:
    ZigBee 3.0理论教程-通用-1-12:安全加密
    2023年度AWS SAP直冲云霄训练营学习分享
    Pytorch从零开始实战06
    《大数据之路:阿里巴巴大数据实践》-第2篇 数据模型篇 -第8章 大数据领域建模综述
    Docker - Oracle Database 23ai Free
    mac电脑版数字图像处理软件:ACDSee Photo Studio 9最新 for Mac
    【C++的OpenCV】第十三课-OpenCV基础强化(一):绝对有用!Mat相关的一系列知识(基础->进阶)
    【缓存】OS层面缓存设计机制
    Javaweb对接Unity(二)
    TiDB数据库架构——TiDB Server
  • 原文地址:https://blog.csdn.net/weixin_55086241/article/details/127564992
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号