java基本类型的自动装箱-拆箱


package com.javabase.p1;



public class TestAPI {

	public static void main(String[] args) {
		
		/**
		 * 基本类型的自动装箱 拆箱
		 */
		//自动装箱
		Integer i = 1;
		
		//上面的相当于下面的分配内存的代码
		int value = 100;
		Integer ijj = new Integer(value);
		System.out.println(ijj);
		
		
		Short sh = 30;
		Long l = 16L;
		Float f = 20f;
		Double h = 20d;
		
		
		//自动拆箱
		int icont = i;
		System.out.println(icont);
		long lgg = l;
		System.out.println(lgg);
		float fgg = f;
		System.out.println(f);
		double dgg = h;
		System.out.println(dgg);

	
	}

}






猜你喜欢

转载自blog.csdn.net/qq_43314793/article/details/90140525