how to make a string array in java code example

Example 1: java new string array

String[] myStringArray = new String[3];
String[] myStringArray = {"a", "b", "c"};
String[] myStringArray = new String[]{"a", "b", "c"};

Example 2: java string array

// array of 5 strings
String[] arr = new String[5]

arr[0] = "Happy";
arr[1] = "Birthday";
arr[2] = "To";
// etc...

Example 3: how to declare string array in java

string[] abc=new string[]{"hai","hello"}

Example 4: 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"
        };

Tags:

Java Example