Java数组

import java.util.Arrays;
public class lzwCode{	
	public static void main(String [] args) {
		int [] arrA = new int[]{1,2,3,4,5}; //在java中数组也是对象
		int [] arrB = {1,2,3,4,5};

		int [] arrC = new int[5];     //(32)21 4748 3647
		long [] arrD = new long[5];   //(64)
		byte [] arrE = new byte[5];   //(8)127
		short [] arrL = new short[5]; //(16)32767 
		
		float [] arrF = new float[5]; //(32)
		double [] arrG = new double[5];//(64)

		char [] arrH = new char[5];//(16)

		String [] arrJ = new String[5];
		boolean [] arrK = new boolean[5]; //(8)
		System.out.println(Arrays.toString(arrA));
		System.out.println(Arrays.toString(arrB));
		System.out.println("====================================");
		System.out.println(Arrays.toString(arrC));
		System.out.println(Arrays.toString(arrD));
		System.out.println(Arrays.toString(arrE));
		System.out.println(Arrays.toString(arrL));
		System.out.println("====================================");
		System.out.println(Arrays.toString(arrF));
		System.out.println(Arrays.toString(arrG));
		System.out.println("====================================");
		System.out.println(Arrays.toString(arrH));
		System.out.println("====================================");
		System.out.println(Arrays.toString(arrJ));
		System.out.println(Arrays.toString(arrK));
    }  
}

控制台结果:




import java.util.Arrays;
public class lzwCode {

	public static void main(String [] args) {
		//数组之间的赋值是引用赋值,没有申请新的存储空间
		int [] a = {1,2,3,4,5};
		System.out.println(Arrays.toString(a));
		int [] b;
		b = a;
		b[1] = 20; //占用一块存储空间的首地址、长度等
		System.out.println(Arrays.toString(b));
		System.out.println(Arrays.toString(a));
	}
}

控制台结果:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值