Skip to content

Instantly share code, notes, and snippets.

@rangalo
Created August 23, 2016 15:02
Show Gist options
  • Save rangalo/7f7af419e85b0a056f27fcd0c624cf45 to your computer and use it in GitHub Desktop.
Save rangalo/7f7af419e85b0a056f27fcd0c624cf45 to your computer and use it in GitHub Desktop.
public static void main (String[] args) {
List<String> fruits = new ArrayList<>();
fruits.add("Apple");
fruits.add("Banana");
fruits.add("Peach");
fruits.add("Orange");
fruits.add("Cherries");
fruits.add("Watermelon");
System.out.println("Before Fruits = " + fruits);
for (String fruit : fruits) {
if (fruit.length() % 2 == 0) {
fruits.remove(fruit);
}
}
System.out.println("After Fruits = " + fruits);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment