fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. Hash h = new Hash();
  15. h.SetHash();
  16. Map<String, String> m = (HashMap<String, String>) h.GetMap().get("key");
  17. System.out.println(m.get("key2"));
  18. }
  19. }
  20.  
  21. class Hash {
  22. private HashMap<String, HashMap<String, String>> wow = new HashMap<String, HashMap<String, String>>();
  23.  
  24. public void SetHash() {
  25. wow.put("key", new HashMap<String, String>());
  26. wow.get("key").put("key2", "val2");
  27. }
  28.  
  29. public HashMap GetMap() {
  30. return wow;
  31. }
  32. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
val2