Java 实例 - 删除链表中的元素

Java 教程 · 2019-02-11 12:43:47

以下实例演示了使用 clear() 方法来删除链表中的元素:

Main.java 文件

import java.util.*; public class Main { public static void main(String[] args) { LinkedList<String> lList = new LinkedList<String>(); lList.add("1"); lList.add("8"); lList.add("6"); lList.add("4"); lList.add("5"); System.out.println(lList); lList.subList(2, 4).clear(); System.out.println(lList); } }

以上代码运行输出结果为:

[1, 8, 6, 4, 5]
[1, 8, 5]

点击查看所有 Java 教程 文章: https://www.codercto.com/courses/l/12.html

查看所有标签

An Introduction to Genetic Algorithms

An Introduction to Genetic Algorithms

Melanie Mitchell / MIT Press / 1998-2-6 / USD 45.00

Genetic algorithms have been used in science and engineering as adaptive algorithms for solving practical problems and as computational models of natural evolutionary systems. This brief, accessible i......一起来看看 《An Introduction to Genetic Algorithms》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器