APISonar


java.util.Stack.removeIf

> java > util > Stack > removeIf
java APIs util APIs Stack APIs removeIf APIs

Example 1
public void givenElementsOnStack_whenRemoveIfIsInvoked_thenAllElementsSatysfyingConditionAreRemoved() {
        Stack<Integer> intStack = new Stack();
        List<Integer> intList = Arrays.asList(1, 2, 3, 4, 5, 6, 7);
        intStack.addAll(intList);
        intStack.removeIf(element -> element < 6);
        assertEquals(2, intStack.size());
    }