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. import java.util.Iterator;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone{
  11.  
  12. public static class CommonHelperUtilService {
  13. private List<String> list = new ArrayList();
  14.  
  15. public CommonHelperUtilService() {
  16. list.add("tomasz");
  17. list.add("zbyszek");
  18. list.add("jakub");
  19. list.add("adam");
  20. }
  21.  
  22. public List<String> getList() {
  23. return list;
  24. }
  25. }
  26.  
  27. public static void main (String[] args) throws java.lang.Exception
  28. {
  29. CommonHelperUtilService commonHelperUtilService = new CommonHelperUtilService();
  30. Iterator<String> iterator = commonHelperUtilService.getList().iterator();
  31. while (iterator.hasNext()) {
  32. if (iterator.next().equals("zbyszek")) {
  33. iterator.remove();
  34. }
  35. }
  36.  
  37. commonHelperUtilService.getList().forEach(System.out::println);
  38. }
  39. }
Success #stdin #stdout 0.08s 711168KB
stdin
Standard input is empty
stdout
tomasz
jakub
adam