package com.yanshu.controller;
import java.util.*;
/**
* 替换,json格式,响应时间
* @author Administrator
*
*/
public class Tihuan {
public static void getreplaceAll()
{
System.out.println("如何替换list数组里面的内容");
List list = Arrays.asList("one 123 three Four five six one three Four".split(" "));
System.out.println("List :"+list);
Collections.replaceAll(list, "123", "hundread");
System.out.println("replaceAll: " + list);
}
public static void main(String[] args) {
getreplaceAll();
}
}
import java.util.*;
/**
* 替换,json格式,响应时间
* @author Administrator
*
*/
public class Tihuan {
public static void getreplaceAll()
{
System.out.println("如何替换list数组里面的内容");
List list = Arrays.asList("one 123 three Four five six one three Four".split(" "));
System.out.println("List :"+list);
Collections.replaceAll(list, "123", "hundread");
System.out.println("replaceAll: " + list);
}
public static void main(String[] args) {
getreplaceAll();
}
}

本文提供了一个使用Java的Collections.replaceAll方法来替换List中特定元素的示例。通过具体代码展示了如何将List数组中的指定字符串进行全局替换。
1008

被折叠的 条评论
为什么被折叠?



