Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsReplaceAllExample2 { public static void main(String[] args) { //Create an list of String List
list = Arrays.asList("one", "two", "one"); System.out.println("Original List:- "+list); boolean b = Collections.replaceAll(list, "one", "three"); System.out.println("Boolean: "+b); System.out.println("Value after replace:- "+list); } }
Output