java 判断集合是否为空
时间: 2023-11-10 18:07:59 浏览: 49
你可以使用 Collection.isEmpty() 方法判断集合是否为空,例如:
```java
List<String> list = new ArrayList<>();
if (list.isEmpty()) {
System.out.println("集合为空");
}
```
这个方法适用于所有 Collection 的子类,包括 List、Set、Queue 等等。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)