From 303ce5bc0eb0a80fbbde26c8f967d248ab73eb8d Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Thu, 25 Dec 2025 15:14:17 +0800 Subject: [PATCH] =?UTF-8?q?day05-=E6=95=B0=E7=BB=84=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=9B=BE=E8=A7=A3&=E6=95=B0=E7=BB=84=E8=B6=8A?= =?UTF-8?q?=E7=95=8C=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day05/src/com/inmind/Demo02_array_memory.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 day05/src/com/inmind/Demo02_array_memory.java diff --git a/day05/src/com/inmind/Demo02_array_memory.java b/day05/src/com/inmind/Demo02_array_memory.java new file mode 100644 index 0000000..043fe95 --- /dev/null +++ b/day05/src/com/inmind/Demo02_array_memory.java @@ -0,0 +1,33 @@ +package com.inmind; +/* +数组的操作 + 二进制:0~1 + 八进制:0~7 + 十进制:0~9 + 十六进制:0~15, 0~9 10(a)、11(b)、12(c)、13(d)、14(e)、15(f) + */ +public class Demo02_array_memory { + public static void main(String[] args) { + //定义一个数据不确定的长度为3的存放整型的数组 + int[] arr = new int[3]; + System.out.println(arr);//[I@50cbc42f + /* + [I@50cbc42f + [I:表示当前是一个数组数据类型,数组存放的数据类型是int + 50cbc42f:表示数组在内存中开辟的空间地址 + + 索引:操作数组指定空间的值,从0开始 + */ + + System.out.println(arr[0]);//0 + System.out.println(arr[1]);//0 + System.out.println(arr[2]);//0 + double[] dArr = new double[3]; + System.out.println(dArr[0]);//0.0 + System.out.println(dArr[1]);//0.0 + System.out.println(dArr[2]);//0.0 + System.out.println("-------------------"); + //注意:数组的最大索引= 数组.length -1; + //System.out.println(dArr[3]);//(数组越界异常)java.lang.ArrayIndexOutOfBoundsException: Index 3 out of bounds for length 3 + } +}