package com.karl1; public class ArrayDemo1 { public static void main(String[] args) { //数组的访问 int[] arr={12,24,36}; //0 1 2 //访问数据 System.out.println(arr[0]); System.out.println(arr[1]); System.out.println(arr[2]); //修改数组中的数据 arr[0]=66; arr[2]=100; System.out.println(arr[0]); System.out.println(arr[1]); System.out.println(arr[2]); //访问数组的元素个数 System.out.println(arr.length); //技巧:获取数组的最大索引,arr.length-1(前提是数组中有数据) System.out.println(arr.length-1); } }
标签:arr,System,访问,数组,println,out From: https://www.cnblogs.com/Karl-hut/p/17437938.html