Java Collections replaceAll() Method21 Mar 2025 | 2 min read 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 provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India