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));
}
}
控制台结果: