Array definition in java:
There are two syntaxes for defining arrays in Java:
type arrayName[];
type[] arrayName;
type is any data type in Java, including basic types and combined types. arrayName is the array name and must be a legal identifier. [ ] indicates that the variable is An array type variable. For example:
int demoArray[];int[] demoArray;
There is no difference between these two forms, and the usage effect is exactly the same. You can choose according to your own programming habits.
String array:
3. String[] str={"a","b"}
2, int[] i=new int[]{0,1}
3, int[] i={0,1}
The above is the detailed content of How to define array length in java. For more information, please follow other related articles on the PHP Chinese website!