zoukankan      html  css  js  c++  java
  • java包装类

    public class PackageDemo {
        public static void main(String[] args) {
    //        // JDK1.5之前的做法
    //        int x =30;
    //        Integer integer = new Integer(x); // 装箱:将基本数据类型变为包装类
    //        int temp = integer.intValue();  //拆箱:将包装类变为基本数据类型
    
            // 自动装箱及拆箱操作
    //        Integer i = 30;           //自动装箱成Integer
    //        Float f = 30.3f;
    //        int x =i;                 //自动拆箱为int
    //        float y =f;
    //
            // 字符串变为基本数据类型
            String str1 = "30";
            String str2 = "30.3";
            int x = Integer.parseInt(str1);
            float f = Float.parseFloat(str2);
            System.out.println("整数乘方:"+x+"*"+x+"="+(x*x));
            System.out.println("小数乘方:"+f+"*"+f+"="+(f*f));
    
            Integer i = new Integer(100);
            int j = 100;
            System.out.println(i == j); //true
    
            Integer a = new Integer(100);
            Integer b = 100;
            System.out.println(a == b); //false
    
            Integer c = 100;
            Integer d = 100;
            System.out.println(c == d); //true
    
            Integer y = 128;
            Integer z = 128;
            System.out.println(y == z); //false
         
    System.out.println(y.equals(z));//true
        }
    }
  • 相关阅读:
    1.Hibernate配置
    CKEditor/FCKEditor的使用
    介绍一个好用的工具类库commons-beanutils
    SpringBean.xml配置
    MVC框架显示层——Velocity技术
    mysql CMD命令
    day 05
    day 04
    day03
    python day 02
  • 原文地址:https://www.cnblogs.com/cathycheng/p/13139533.html
Copyright © 2011-2022 走看看