Java Collection removeIf() MethodThe removeIf() method of Java Collection Interface removes the elements of this queue that satisfies the given predicate filter. SyntaxParametersThe parameter 'filter' represents a predicate which returns true for the elements to be removed. Return Value:The removeIf () method returns a Boolean value 'true' if the collection has removed any element, else it returns 'false'. ThrowsUnsupportedOperationException- if the elements cannot be removed from this collection. NullPointerException- if the specified filter is null. Example 1Test it NowOutput: Total no : [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20] Table of 2 = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20] Example 2Test it NowOutput: People who passed the exam : 1. Reema has passed the exam with 98 marks. 2. Raj has passed the exam with 71 marks. 3. Ravi has passed the exam with 47 marks. Example 3Test it NowOutput: Albabets : [A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z] Vowels = [A, E, I, O, U] Next TopicJava-Collection |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India