1. Definition
An array is a reference data type composed of the same type of data in sequence.
2. Declaration
Syntax format
数据类型[] 数组名; int[] myIntArray; char[] ch; String[] strArray;
Data type
数组名[]; int myIntArray[]; char[] ch; String strArray[];
3.Creation method
//数组创建1:引用,对象,元素 int[] aa; int[] a = new int[10]; int[] aaa = new int[0]; //空数组 //创建方式2:声明,创建, int[] b = new int[] {1,2}; String[] strings = new String[] {"Hello World"}; //创建方式3: int[] c = {1,2,3}; String[] strings2 = {"World"};
The above is the detailed content of How to declare a one-dimensional array in java. For more information, please follow other related articles on the PHP Chinese website!