提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
它使您可以根据索引号删除元素,如下所示:emps.remove(0);
import java.util.ArrayList; public class Main {/** nowjava 提 供 **/ public static void main(String[] args) { ArrayList<Employee> emps = new ArrayList<Employee>(); // add employees to array list emps.add(new Employee("A")); emps.add(new Employee("T")); emps.add(new Employee("K")); // print array list System.out.println(emps); emps.remove(0); // print the array list again System.out.println(emps); } }/**n o w j a v a . c o m - 时代Java**/ class Employee{ private String name; public Employee(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) {