语法:
数据类型[ ] 数组名称 = {元素1,元素2,元素3};
public class Demo1 {
public static void main(String[] args) {
int[] arr = {0,1,2,3};
System.out.println(arr);
System.out.println(arr[0]);
System.out.println(arr[1]);
System.out.println(arr[2]);
System.out.println(arr[3]);
}
}
运行结果: