fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. List<String> list = new ArrayList<String>();
  11. String string = "";
  12. Ideone(String a) { string = a; }
  13.  
  14. public String getString() {
  15. return this.string;
  16. }
  17.  
  18. public static void main (String[] args) throws java.lang.Exception
  19. {
  20. Ideone idA = new Ideone("a");
  21. Ideone idB = new Ideone("b");
  22.  
  23. Map<String,List<Ideone>> map = new HashMap();
  24.  
  25. map.put("john",new ArrayList<Ideone>(Arrays.asList(idA, idB)));
  26.  
  27. List<Ideone> stringList = map.get("john");
  28.  
  29. for (Ideone id: stringList) {
  30. System.out.println(id.getString());
  31. }
  32. }
  33. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
a
b