Return | Method | Summary |
---|---|---|
static<T> boolean | replaceAll(List<T> list, T oldVal, T newVal) | Replaces all occurrences of one specified value in a list with another. |
import java.util.Collections;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Vector<String> v = new Vector<String>();
v.add("A");
v.add("B");
v.add("A");
v.add("C");
v.add("D");
System.out.println(v);
Collections.replaceAll(v, "A", "java2s.com");
System.out.println(v);
}
}
The output:
[A, B, A, C, D]
[java2s.com, B, java2s.com, C, D]
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |