1.数组就是一组数据,数据类型相同
2.数组的声明
3.数组的初始化
package org.cindy.array; public class Array { public static void main(String[] args) { //int[] x = new int[5]; //声明数组长度 /* x[0] = 1; x[1] = 2; x[2] = 3; x[3] = 4; x[4] = 5; */ int[] x = new int[]{1,2,3,4,5}; for (int i = 0; i < x.length; i++){ System.out.println(x[i]); } //char[] c = new char[3]; //c[0] = ‘a‘; //c[1] = ‘b‘; //c[2] = ‘c‘; char[] c = new char[]{‘a‘, ‘b‘, ‘c‘}; for (int j = 0; j < c.length; j++){ System.out.println(c[j]); } //float[] f; //String[] s; } }
时间: 2024-10-21 21:46:31