java基礎數據類型大小

可以通過基礎類型對應的包裝類獲取基礎類型的大小,如char,可以查看Character類:
 


    /**
     * The number of bits used to represent a {@code char} value in unsigned
     * binary form, constant {@code 16}.
     *
     * @since 1.5
     */
    public static final int SIZE = 16;

    /**
     * The number of bytes used to represent a {@code char} value in unsigned
     * binary form.
     *
     * @since 1.8
     */
    public static final int BYTES = SIZE / Byte.SIZE;

可知Character佔用2字節,16位.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章