arraylist removeif 28 29 method in java

Solutions on MaxInterview for arraylist removeif 28 29 method in java by the best coders in the world

showing results for - "arraylist removeif 28 29 method in java"
Raphael
28 Jul 2016
1import java.util.ArrayList;
2public class ArrayListRemoveIfMethodExample
3{
4   public static void main(String[] args)
5   {
6      ArrayList<Integer> al = new ArrayList<Integer>();
7      al.add(15);
8      al.add(8);
9      al.add(58);
10      al.add(19);
11      // remove numbers divisible by 2
12      al.removeIf(n -> (n % 2 == 0));
13      // print list
14      for(int a : al)
15      {
16         System.out.println(a);
17      }
18   }
19}