/*1. Three ways to initialize a one-dimensional array 2. Demonstrates the length property of an array, and gets the array lengths with length*/ Public classLinear_array { Public Static voidMain (String args[]) {intArr1[] =New int[6]; arr1[0]=1; DoubleArr2[] =New Double[]{9.0,5.5,3.6,6.9,13.4}; intArr3[] = {0,2,3,4,2,00,8}; System.out.println (arr1 [0]);//output:1System.out.println (arr2 [1]);//output:5.5System.out.println (ARR3 [2]);//Output:3//System.out.println (ARR3 [9]); /*output:exception in thread "main" Java.lang.arrayindexoutofboundsexception:9 at linear_array.ma In (linear_array.java:16) throws array subscript overflow exception because subscript is out of bounds*/ //The subscript of an array starts with 0, and the array's maximum subscript is a number-1 intArr4[] =New int[9]; System.out.println ("The length of the array arr4 is:" + arr4.length);//Output:9 intArr5[] =New int[4+3]; System.out.println ("The length of the array arr5 is:" + arr5.length);//Output:7 /*the length of an array can only be represented by an integer of ≧0, which is usually an integer of >0, equal to 0 o'clock the length of the meaningless array may be expressed as a constant with an expression that indicates the value of length.*/ }}
: https://gitee.com/sxyin/codes/7n3lji02udgkyvxt8r5ao79
"Java" one-dimensional arrays