Monday, May 23, 2011

Multi Dimension Array Test Program

========================================
package java_demo;

public class MultiDimenDemo {

    /**
     * @param args
     */
    public static void main(String[] args) {
        String[][] names = {{"Mr. ", "Mrs. ", "Ms. "},
                            {"Smith", "Jones"}};
        System.out.println(names[0][0] + names[1][0]); //Mr. Smith
        System.out.println(names[0][2] + names[1][1]); //Ms. Jones
    }
}


=========================================

Out Put:
Mr. Smith
Ms. Jones


How arrays pick up :

{{"Mr. ", "Mrs. ", "Ms. "}, ---> [0][0] , [0][1] , [0][2],
  {"Smith", "Jones"}};       ----> [1][0] , [1][1]



[0][0] , [0][1] , [0][2], [0][3], [0][4]
[1][0] , [1][1] , [1][2], [1][3], [1][4] 



Good Article on JAVA!
http://download.oracle.com/javase/tutorial/java/index.html






No comments:

Post a Comment