Java List isEmpty() 方法

2025年3月24日 | 1 分钟阅读

List 接口的 isEmpty() 方法如果此列表不包含任何元素,则返回布尔值“true”。

语法

参数

不适用

指定者:

Collection<E> 接口中的 isEmpty()

返回

如果此列表不包含任何元素,则 isEmpty() 方法返回布尔值“true”,否则返回 false。

示例 1

输出

Enter elements as this list is empty.

示例 2

输出

Elements are already present in this list.
List : [null]
下一主题Java List