Java AbstractSequentialList类的remove()方法
remove()AbstractSequentialList类的方法删除此列表中指定位置的元素。
语法如下
E remove(int index)
在此,index是要删除的元素的索引。要使用Java中的AbstractSequentialList类,您需要导入以下包
import java.util.AbstractSequentialList;
以下是remove()在Java中实现AbstractSequentialList方法的示例
示例
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]
热门推荐
10 祝女儿简短祝福语大全
11 大学新年祝福语简短创意
12 元旦适合的祝福语简短
13 朋友出远门祝福语简短
14 初六简短的祝福语
15 祝男孩生日祝福语简短
16 同事调离的祝福语简短
17 拜年红包的祝福语简短
18 妈妈生日祝福语简短励志