Java AbstractSequentialList 类的 remove() 方法
AbstractSequentialList 类的 remove() 方法会删除此列表中位于指定位置的元素。
语法如下所示
E remove(int index)
此处,index 是要删除的元素的索引。要在 Java 中使用 AbstractSequentialList 类,需要导入以下包
import java.util.AbstractSequentialList;
以下示例介绍了如何在 Java 中实施 AbstractSequentialList remove() 方法
示例
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(25); absSequential.add(32); absSequential.add(40); absSequential.add(55); absSequential.add(60); absSequential.add(70); absSequential.add(90); System.out.println("Elements in the AbstractSequentialList = "+absSequential); absSequential.remove(3); absSequential.remove(5); System.out.println("Updated AbstractSequentialList = "+absSequential); } }
输出
Elements in the AbstractSequentialList = [25, 32, 40, 55, 60, 70, 90] Updated AbstractSequentialList = [25, 32, 40, 60, 70]
广告