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) {
  11. GettingEmSafety safety = new GettingEmSafety();
  12. System.out.println(safety.getValues());
  13. safety.getValues().removeAll(safety.getValues());
  14. System.out.println(safety.getValues());
  15. }
  16. }
  17.  
  18. class GettingEmSafety {
  19. private final Collection<String> values;
  20.  
  21. public GettingEmSafety() {
  22. values = new ArrayList<>();
  23. values.add("First");
  24. values.add("Second");
  25. }
  26.  
  27. private class MyCol extends ArrayList<String> {
  28. public MyCol(Collection c) {
  29. super(c);
  30. }
  31.  
  32. @Override
  33. public boolean removeAll(Collection c) {
  34. return true;
  35. }
  36. }
  37.  
  38. public Collection<String> getValues() {
  39. MyCol col = new MyCol(this.values);
  40. return col;
  41. }
  42. }
Success #stdin #stdout 0.09s 320256KB
stdin
Standard input is empty
stdout
[First, Second]
[First, Second]