您好,欢迎访问一九零五行业门户网

Java 实例 - List 元素替换

以下实例演示了如何使用 collections 类的 replaceall() 来替换list中所有的指定元素:
/* author by w3cschool.cc main.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); } }
以上代码运行输出结果为:
list :[one, two, three, four, five, six, one, three, four] replaceall: [hundread, two, three, four, five, six, hundread, three, four]
以上就是java 实例 - list 元素替换的内容。
其它类似信息

推荐信息