zoukankan      html  css  js  c++  java
  • JavaSE 高级 第1节 基本数据类型的封装类

    2016-07-05

    1,如何查看API

    2,byte Byte
    char Character
    short Short
    int Integer
    long Long
    float Float
    double Double
    boolean Boolean

    3,自动装箱与拆箱
    基本数据类型 转换为 封装类型:装箱
    封装类型 转换为 基本类型:拆箱

    拆箱示例:
    Integer i1=new Integer(10);
    int i2=i1;

    装箱示例:
    int i3=9;
    Integer i4=i3;

    package com.java1995;
    
    public class TestBoolean {
        
        public static void main(String[] args) {
            Boolean b1=new Boolean("true");
            System.out.println(b1.toString());
            
            Boolean b2=new Boolean(false);
        }
    
    }
    package com.java1995;
    
    public class TestDouble {
        
        public static void main(String[] args) {
            System.out.println("Double的最大值:"+Double.MAX_VALUE);
            System.out.println("Double的最小值:"+Double.MIN_VALUE);
            double d=Double.parseDouble("123");
            System.out.println(d);
            System.out.println(Double.POSITIVE_INFINITY);
            System.out.println(Double.NEGATIVE_INFINITY);
        }
    
    }

    package com.java1995;
    
    public class TestInteger {
        
        public static void main(String[] args) {
            System.out.println("Integer的最大值:"+Integer.MAX_VALUE);
            System.out.println("Integer的最小值:"+Integer.MIN_VALUE);
    
            int i=Integer.parseInt("123");
            System.out.println(i);
    
            String s=Integer.toBinaryString(10);    
            System.out.println(s);
        }
    
    }

    package com.java1995;
    
    public class Test {
        public static void main(String[] args) {
            //自动拆箱
            Integer i1=new Integer(10);
            int i2=i1;
            System.out.println(i2);
            //自动装箱
            int i3=9;
            Integer i4=i3;
            System.out.println(i4);
        }
    
    }

    【参考资料】

    [1] Java轻松入门经典教程【完整版】

  • 相关阅读:
    写给自己的话
    软件开发之技能梳理
    《创新者的窘境》读书笔记
    我的四年踩坑史以及思考
    认识问题和求解问题的一种思考框架
    《时间的秩序》读书笔记
    从JSON中自动生成对应的对象模型
    考考你:一道题引发的小思考
    哈!如果一生只如花样短暂
    使用正则表达式抽取所需文本
  • 原文地址:https://www.cnblogs.com/cenliang/p/5642504.html
Copyright © 2011-2022 走看看