Advertisement
nordlaender

java iterators

Jun 25th, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. List<String> myList = new ArrayList<String>();
  2.  
  3. myList.add("1");
  4. myList.add("2");
  5. myList.add("3");
  6. myList.add("4");
  7. myList.add("5");
  8.  
  9. Iterator<String> it = myList.iterator();
  10.  
  11. while(it.hasNext()){
  12.     String value = it.next();
  13.     System.out.println("List Value:"+value);
  14.     if(value.equals("3")) myList.remove(value);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement