包装类

包装类

常见的类和对象

byte short int long

float double

char boolean

包装类

public class DataType {
    public static void main(String[] args) {
        /* TODO 包装类
        Byte b = null;
        Short s = null;
        Integer i = null;
        Long lon = null;
        Float f = null;
        Double d = null;
        Character c = null;
        Boolean bln = null;
        */
        int i = 10;
        //Integer integer = new Integer(i); 不推荐使用
        //将基本数据类型转换为包装类
        Integer i1 = Integer.valueOf(i);

        //自动装箱
        Integer i2 = i;

        //自动拆箱
        int i3 = i1.intValue();
        int i4 = i;

    }
}

posted @   LaViez  阅读(13)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 在鹅厂做java开发是什么体验
· 百万级群聊的设计实践
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
· 永远不要相信用户的输入:从 SQL 注入攻防看输入验证的重要性
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
点击右上角即可分享
微信分享提示