java基本类型占多少字节数



package com.javabase.p1;

public class Testp {

	public static void main(String[] args) {
		
		
		//byte占的空间宽度 bit位   除以8就是字节
		int i0 = Byte.SIZE; 
		System.out.println("byte   " + (i0 / 8) + "  字节");
		
		int i1 = Character.SIZE;	
		System.out.println("char   " + (i1 / 8)+ "  字节");
		
		int i2 = Integer.SIZE;		
		System.out.println("int   " + (i2 / 8)+ "  字节");
		
		int i3 = Short.SIZE;		
		System.out.println("short   " + (i3 / 8)+ "  字节");
		
		int i4 = Long.SIZE;			
		System.out.println("long   " + (i4 / 8)+ "  字节");
		
		//浮点型占空间宽度 bit
		int i5 = Float.SIZE;		
		System.out.println("float   " + (i5 / 8)+ "  字节");
		
		int i6 = Double.SIZE;		
		System.out.println("double   " + (i6 / 8)+ "  字节");
	
		

	}

}




你可能感兴趣的:(java)