Java ConcurrentLinkedQueue isEmpty() 方法

2024年10月21日 | 2 分钟阅读

ConcurrentLinkedQueue 类的 isEmpty() 方法返回一个布尔值 true,如果定义的队列不包含任何元素。ConcurrentLinkedQueue 类的 isEmpty() 方法被 AbstractCollection<E> 类中的 isEmpty() 方法覆盖。

语法

参数

不适用

指定者:

ConcurrentLinkedQueue 类的 isEmpty() 方法由 Collection<E> 接口中的 isEmpty() 方法指定。

返回值

如果定义的队列不包含任何元素,isEmpty() 方法返回布尔值 true。

示例 1

输出

Elements are : [1, 2, 3, 4, 5]

示例 2

输出

isEmpty() method returns true
Add some elements because the queue is empty.

示例 3

输出

Enter five names 
1. Name = Reema
2. Name = Himanshu
3. Name = Rahul
Queue : [Reema, Himanshu, Rahul]