JAVA獲取基本類型的字節數大小

public class Main {
    public static void main(String[] args) {
        System.out.println("The size of short is "+Short.SIZE/8+" bytes.");
        System.out.println("The size of int is "+Integer.SIZE/8+" bytes.");
        System.out.println("The size of long is "+Long.SIZE/8+" bytes.");
        System.out.println("The size of long long is "+Long.SIZE/8+" bytes.");
    }
}

The size of short is 2 bytes.
The size of int is 4 bytes.
The size of long is 8 bytes.
The size of long long is 8 bytes.

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