ERROR - The method removeIf(Predicate) in the type Collection<[Integer]> is not applicable for the arguments ()

Error

The method removeIf(Predicate<? super [Integer]>) in the type Collection<[Integer]> is not applicable for the arguments ()

Error Type

Compile Time ( Java 8 )

Sample Code

List<Integer> intList = new ArrayList<Integer>();
intList.add(6);
intList.add(5);
intList.removeIf();

Cause

The method removeIf expects the predicate for removal of collection elements.

Possible Resolution

Specify the Predicate using Lambda Expression

List<Integer> intList = new ArrayList<Integer>();
intList.add(6);
intList.add(5);
intList.removeIf(e->e>5);

or Specify null for removing all elements.

List<Integer> intList = new ArrayList<Integer>();
intList.add(6);
intList.add(5);
intList.removeIf(null);