java 2d array initialization

Solutions on MaxInterview for java 2d array initialization by the best coders in the world

showing results for - "java 2d array initialization"
Giulio
31 Jul 2018
1class TwoDimensionalArray {
2
3    public static void main(String[] args) {
4        String[][] salutation = {
5            {"Mr. ", "Mrs. ", "Ms. "},
6            {"Kumar"}
7        };
8
9        // Mr. Kumar
10        System.out.println(salutation[0][0] + salutation[1][0]);
11
12        // Mrs. Kumar
13        System.out.println(salutation[0][1] + salutation[1][0]);
14    }
15}
16
17The output from this program is:
18
19Mr. Kumar
20Mrs. Kumar