fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5.  
  6.  
  7. class Ideone
  8. {
  9. public static <T> List<List<T>> make() {
  10. List<List<T>> x = new ArrayList<List<T>>();
  11. x.add(new ArrayList<T>());
  12. x.add(new ArrayList<T>());
  13. x.add(new ArrayList<T>());
  14. return x;
  15. }
  16.  
  17. public static <T> void consume(List<List<T>> x) {
  18. for (List<T> y : x) {
  19. for (T v : y) {
  20. System.out.print(v.toString() + " ");
  21. }
  22. System.out.println();
  23. }
  24. }
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28. List<List<Integer>> x = Ideone.<Integer>make();
  29. x.get(0).add(0);
  30. x.get(1).add(1);
  31. x.get(2).add(2);
  32. x.get(0).add(3);
  33. x.get(1).add(4);
  34. x.get(2).add(5);
  35. x.get(0).add(6);
  36. x.get(1).add(7);
  37. x.get(2).add(8);
  38. consume(x);
  39. }
  40. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
0 3 6 
1 4 7 
2 5 8