Files
javaSE-0113/day05/src/com/inmind/array01/Demo02.java

35 lines
1.2 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind.array01;
/*
二进制0~1
八进制0~7
十进制0~9
十六进制0~15 0~9 10a、11b、12(c)、13(d)、14(e)、15(f)
注意:所有的基本数据类型,保存的是值,而引用数据类型,保存的是地址值
*/
public class Demo02 {
public static void main(String[] args) {
//定义一个整数数组
int[] arr1 = new int[3];
int a = 3;
System.out.println(a);//3 打印了变量a中的值
//[I@4eec7777
/*
[I@4eec7777
[I:表示当前是一个数组类型里面存放的数据类型是int
4eec7777表示数组在堆内存中开辟的空间地址采用十六进制展示地址值
*/
System.out.println(arr1);//[I@4eec7777
System.out.println(arr1[0]);//引用数据类型,只要定义就会有默认值!!!!
System.out.println("---------------------------");
//定义一个double数组
// double[] arr2 = new double[]{0.1,0.2,0.3,0.4};
double[] arr2 = {0.1,0.2,0.3,0.4};
System.out.println(arr2);//[D@3b07d329
System.out.println(arr2[1]);//0.2
}
}