zoukankan      html  css  js  c++  java
  • Java中类型的长度

    介绍:

    Java中有8种基本类型,分别是boolean, char, byte, short, int, long, float, double。他们的长度固定,不是对象。对于有必要将基本类型作为对象处理的情况,java提供了包装器类,这样有个好处是Java编译器和运行时能够更容易的进行优化。由于java的可移植性,每个类型在不同的平台上大小一致。

    代码实现:

    package self;
    
    /**
     * Created by Jimmy on 2015/5/18.
     */
    public class sizeof {
        public static void main(String[] args){
            System.out.println("Integer: " + Integer.SIZE/8);           // 4
            System.out.println("Short: " + Short.SIZE/8);               // 2
            System.out.println("Long: " + Long.SIZE/8);                 // 8
            System.out.println("Byte: " + Byte.SIZE/8);                 // 1
            System.out.println("Character: " + Character.SIZE/8);       // 2
            System.out.println("Float: " + Float.SIZE/8);               // 4
            System.out.println("Double: " + Double.SIZE/8);             // 8
            //System.out.println("Boolean: " + Boolean.SIZE/8);         //true/false
        }
    }

     输出:

    1 Integer: 4
    2 Short: 2
    3 Long: 8
    4 Byte: 1
    5 Character: 2
    6 Float: 4
    7 Double: 8
  • 相关阅读:
    正则表达式练习
    Linux下文件删除的原理
    (转)linux grep 正则表达式
    linux 需要记忆的知识
    linux 常用命令
    TestNG测试方法
    TestNG配置注解
    jquery 获取和设置 select下拉框的值
    Kings(状压DP)
    Tirp(状压DP)
  • 原文地址:https://www.cnblogs.com/dracohan/p/4746750.html
Copyright © 2011-2022 走看看