java.util.concurrent.ConcurrentSkipListSet.isEmpty()方法是Java中的内置函数,用于检查此集合是否为空。
用法:
ConcurrentSkipListSet.isEmpty()
参数:该函数不接受任何参数。
返回值:该函数返回一个布尔值。如果ConcurrentSkipListSet为空,则返回true,否则返回false。
以下示例程序旨在说明ConcurrentSkipListSet.IsEmpty()方法:
示例1:在此程序中,ConcurrentSkipListSet为非空。
// Java Program to demonstrate isEmpty()
// method of ConcurrentSkipListSet()
import java.util.concurrent.*;
class ConcurrentSkipListSetIsEmptyExample1 {
public static void main(String[] args)
{
// Creating a set object
ConcurrentSkipListSet<Integer> Lset =
new ConcurrentSkipListSet<Integer>();
// Adding elements to this set
for (int i = 10; i <= 50; i += 10)
Lset.add(i);
// Checks if this set is empty or not
if (Lset.isEmpty())
System.out.println("The set is empty.");
else
System.out.println("The set is non-empty.");
}
}
输出:
The set is non-empty.
示例2:在此程序中,ConcurrentSkipListSet为空。
// Java program to demonstrate isEmpty()
// method of ConcurrentSkipListSet()
import java.util.concurrent.*;
class ConcurrentSkipListSetIsEmptyExample2 {
public static void main(String[] args)
{
// Creating a set object
ConcurrentSkipListSet<Integer> Lset =
new ConcurrentSkipListSet<Integer>();
// Checks if this set is empty or not
if (Lset.isEmpty())
System.out.println("The set is empty.");
else
System.out.println("The set is non-empty.");
}
}
输出:
The set is empty.
参考: https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#add(E)
相关用法
- Java ConcurrentSkipListSet contains()用法及代码示例
- Java ConcurrentSkipListSet last()用法及代码示例
- Java ConcurrentSkipListSet add()用法及代码示例
- Java ConcurrentSkipListSet first()用法及代码示例
- Java ConcurrentSkipListSet higher()用法及代码示例
- Java ConcurrentSkipListSet headSet()用法及代码示例
- Java ConcurrentSkipListSet floor()用法及代码示例
- Java ConcurrentSkipListSet descendingIterator()用法及代码示例
- Java ConcurrentSkipListSet ceiling()用法及代码示例
- Java ConcurrentSkipListSet pollFirst()用法及代码示例
- Java ConcurrentSkipListSet spliterator()用法及代码示例
- Java ConcurrentSkipListSet subSet()用法及代码示例
- Java ConcurrentSkipListSet removeAll()用法及代码示例
- Java ConcurrentSkipListSet pollLast()用法及代码示例
- Java ConcurrentSkipListSet equals()用法及代码示例
注:本文由纯净天空筛选整理自rupesh_rao大神的英文原创作品 ConcurrentSkipListSet isEmpty() method in Java。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。