Java示例替换列表中的元素


Java示例替换列表中的元素

import java.util.*;



public class Main {

   public static void main(String[] args) {

      List list = Arrays.asList("one Two three Four five six one three Four".split(" "));

      System.out.println("List :"+list);

      Collections.replaceAll(list, "one", "hundread");

      System.out.println("replaceAll: " + list);

   }

}