摘要: package com.steven.array; public class ArrayDemo2 { public static void main(String[] args) { int[] arrays = {1, 2, 3, 4, 5}; // 打印数组中所有的元素 for (int i 阅读全文
posted @ 2020-06-03 23:46 玉面小飞龙 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 数组下标合法区间是:[0, length-1],如果越界就会报错; int[] arrays = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; System.out.println(arrays[10]); ArrayIndexOutOfBoundsException:数组下标越 阅读全文
posted @ 2020-06-03 23:07 玉面小飞龙 阅读(225) 评论(0) 推荐(0) 编辑
摘要: 1、Java内存: 2、画图分析: 3、三种初始化 静态初始化: int[] a = {1, 2, 3}; Man[] mans = {new Man(1,1), new Man(2,2)}; 动态初始化: int [] a = new int[2]; a[0] = 1; a[1] = 2; 数组的 阅读全文
posted @ 2020-06-03 22:52 玉面小飞龙 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 1、数组的定义 数组是相同类型数据的有序集合; 数组描述的是相同类型的若干个数据,按照一定的先后次序排列组合而成; 其中,每一个数据称作一个数组元素,每个数组元素可以通过一个下标来访问他们。 2、数组的声明创建 首先必须声明数组变量,才能在程序中使用数组。下面是声明数组变量的语法: dataType 阅读全文
posted @ 2020-06-03 22:17 玉面小飞龙 阅读(232) 评论(0) 推荐(0) 编辑