arr java code example
Example 1: how to declare array java
int intArray[];
intArray = new int[20];
int[] intArray = new int[20];
Example 2: java array
String[] cars = new String[4];
cars[0] = "Volvo";
cars[1] = "BMW";
cars[2] = "Ford";
cars[3] = "Mazda";
Example 3: array java
int[] intArray = new int[20];
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
Example 4: java array
int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int newarr[] = new int[maxSize];
newarr[pos] = n;
for (i = 0; i < maxSize; i++) { newarr[i] = arr[i]; }