how to write an array code example

Example 1: creating array java

int[] intArray = new int[]{ 1,2,3,4,5,6,7,8,9,10 }

Example 2: arrays in java

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

Example 3: an array of names for java

String[] names = {
            "Liam",
            "Olivia",
            "Noah",
            "Emma",
            "Oliver",
            "Ava",
            "William",
            "Sophia",
            "Elijah",
            "Isabella",
            "James",
            "Charlotte",
            "Benjamin",
            "Amelia",
            "Lucas",
            "Mia",
            "Mason",
            "Harper",
            "Ethan",
            "Evelyn"
        };

Example 4: How to use an array

var fruits=["orange","apple"];

Example 5: how to define array

int array[N];

Example 6: how to declare an array

redim Friday(NumFRdays)

Tags:

Java Example