Create an array code example

Example 1: arrays in java

int[] intArray = new int[20];
String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};

Example 2: how to use arrays java

// How to use arrays 
// Julian
 public static void main(String[] args)
   {
   // Initialize array
      int[] arrNum = {25, 23, 15, 20, 24};
   // Recorrerlo
      for(int a = 0; a < arrNum.length; a++)
      {
         System.out.println(arrNum[a]);
      }
   }

Example 3: string array in java methods

String[] vowels = { "a", "e", "i", "o", "u" };
System.out.println(vowels);
System.out.println(Arrays.toString(vowels));

Example 4: Java create array of array

String[][] arrays = new String[][] { array1, array2, array3, array4, array5 };

Example 5: how to create an array in javascript

let fruits = ['Apple', 'Banana']

console.log(fruits.length)
// 2

Example 6: arrays in java

int[] arr;			// Declaration dataType can int, float etc.
arr = new int[N];	// Allocation N = 0 to 2,147,483,647.

Tags:

Java Example