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. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. List<List<String>> list = new ArrayList<List<String>>() {{
  14. add( new ArrayList<String>(Arrays.asList("A", "B")) );
  15. add( new ArrayList<String>(Arrays.asList("C", "D")) );
  16. }};
  17.  
  18. System.out.println("\nlist dump!");
  19. for (List<String> sl : list) {
  20. for (String s : sl) {
  21. System.out.print(s);
  22. }
  23. }
  24.  
  25. // CLONE
  26. List<List<String>> clone = new ArrayList<>(list);
  27.  
  28. // REMOVE
  29. list.get(0).remove(1);
  30.  
  31. System.out.println("\nlist dump!!");
  32. for (List<String> sl : list) {
  33. for (String s : sl) {
  34. System.out.print(s);
  35. }
  36. }
  37.  
  38. System.out.println("\nclone dump!!");
  39. for (List<String> sl : clone) {
  40. for (String s : sl) {
  41. System.out.print(s);
  42. }
  43. }
  44. }
  45. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
list dump!
ABCD
list dump!!
ACD
clone dump!!
ACD