Java Collections replaceAll() MethodLast Updated : 17 Mar 2025 The replaceAll() method of Java Collections class is used to replace all occurrences of one specified value in a list with the other specified value. SyntaxFollowing is the declaration of replaceAll() method: Parameter
ReturnsThe replaceAll() method returns true if the list contained one or more elements e such that (oldVal==null ? e==null : oldVal.equals(e)). ExceptionsUnsupportedOperationException- It throws this exception if the specified list or its list-iterator does not support the set operation. Compatibility VersionJava 1.4 and above Example 1Output: Initial values are :[Java, SSSIT, HINDI100, Java] Value after replace :[TpointTech, SSSIT, HINDI100, TpointTech] Example 2Output: Original List:- [one, two, one] Boolean: true Value after replace:- [three, two, three] Example 3Output: Original List: [10, 20, 10, 40, 50, 10] Boolean: true Value after Replace: [400, 20, 400, 40, 50, 400] Next TopicJava Collections Class |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India