Friday, February 24, 2012

2 Dimension Set in Java

2 Dimension Set in Java
Simple stuff, just a tutorial.

import java.util.HashMap;

class Trial {

public static void main(String[] args) {
System.out.println("*** start ***");

try {

HashMap<Integer, HashMap<Integer, String>> mapHolder =
new HashMap<Integer, HashMap<Integer, String>>();

HashMap<Integer, String> tmpMap1 = new HashMap<Integer, String>();
tmpMap1.put(1, "Judy");
tmpMap1.put(2, "Caty");

HashMap<Integer, String> tmpMap2 = new HashMap<Integer, String>();
tmpMap2.put(1, "John");
tmpMap2.put(2, "Charles");
tmpMap2.put(3, "Mike");

mapHolder.put(1, tmpMap1);
mapHolder.put(2, tmpMap2);

System.out.println("2nd of the 2nd : " + mapHolder.get(2).get(2)); // Charles

} catch (Exception e) {
e.printStackTrace();
}

System.out.println("*** end ***");
}
}

http://pastebin.com/uh6Gy8iS