Java 实例 - 删除数组元素
Java 教程
· 2019-02-10 12:26:34
以下实例演示了如何使用 remove () 方法来删除数组元素:
Main.java 文件
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<String> objArray = new ArrayList<String>();
objArray.clear();
objArray.add(0,"第 0 个元素");
objArray.add(1,"第 1 个元素");
objArray.add(2,"第 2 个元素");
System.out.println("数组删除元素前:"+objArray);
objArray.remove(1);
objArray.remove("第 0 个元素");
System.out.println("数组删除元素后:"+objArray);
}
}
以上代码运行输出结果为:
数组删除元素前:[第 0 个元素, 第 1 个元素, 第 2 个元素] 数组删除元素后:[第 2 个元素]
点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html
Developing Large Web Applications
Kyle Loudon / Yahoo Press / 2010-3-15 / USD 34.99
As web applications grow, so do the challenges. These applications need to live up to demanding performance requirements, and be reliable around the clock every day of the year. And they need to withs......一起来看看 《Developing Large Web Applications》 这本书的介绍吧!