Java 实例 - List 元素替换
Java 教程
· 2019-02-11 19:26:49
以下实例演示了如何使用 Collections 类的 replaceAll() 来替换List中所有的指定元素:
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", "hundrea");
System.out.println("replaceAll: " + list);
}
}
以上代码运行输出结果为:
List :[one, Two, three, Four, five, six, one, three, Four] replaceAll: [hundrea, Two, three, Four, five, six, hundrea, three, Four]
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
Python源码剖析
陈儒 / 电子工业出版社 / 2008-6 / 69.80元
作为主流的动态语言,Python不仅简单易学、移植性好,而且拥有强大丰富的库的支持。此外,Python强大的可扩展性,让开发人员既可以非常容易地利用C/C++编写Python的扩展模块,还能将Python嵌入到C/C++程序中,为自己的系统添加动态扩展和动态编程的能力。. 为了更好地利用Python语言,无论是使用Python语言本身,还是将Python与C/C++交互使用,深刻理解Pyth......一起来看看 《Python源码剖析》 这本书的介绍吧!