Answers for "Java 2d array initialization"

1

Java 2d array initialization

class TwoDimensionalArray {

    public static void main(String[] args) {
        String[][] salutation = {
            {"Mr. ", "Mrs. ", "Ms. "},
            {"Kumar"}
        };

        // Mr. Kumar
        System.out.println(salutation[0][0] + salutation[1][0]);

        // Mrs. Kumar
        System.out.println(salutation[0][1] + salutation[1][0]);
    }
}

The output from this program is:

Mr. Kumar
Mrs. Kumar
Posted by: Guest on March-29-2021

Code answers related to "Java 2d array initialization"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language