public class ArrayDemo3{ public static void main(String[] args){ //定义数组 并同时赋值 int[] arr=new int[]{3,4,5,8,2}; System.out.println(arr.length); System.out.println(arr[arr.length-1]); //定义数组直接用大括号赋值 int[] arr1={22,56,89}; System.out.println(arr1[arr1.length-1]); //为数组赋值 arr1[2]=111; System.out.println(arr1[arr1.length-1]); } }