Java中的AbstractSequentialList的isEmpty()方法
AbstractSequentialList类的isEmpty()方法用于检查链表是否为空。如果为空,则返回TRUE,否则返回FALSE。
语法如下。
public boolean isEmpty()
要在Java中使用AbstractSequentialList类,需要导入以下包。
import java.util.AbstractSequentialList;
以下是一个在Java中实现AbstractSequentialList isEmpty()方法的示例。
示例
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(110); absSequential.add(320); absSequential.add(400); absSequential.add(550); absSequential.add(600); absSequential.add(700); absSequential.add(900); System.out.println("Elements in the AbstractSequentialList = "+absSequential); System.out.println("Is the AbstractSequentialList empty? "+ absSequential.isEmpty()); } }
输出
Elements in the AbstractSequentialList = [110, 320, 400, 550, 600, 700, 900] Is the AbstractSequentialList empty? False
示例
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); System.out.println("Elements in the AbstractSequentialList = "+absSequential); System.out.println("Is the AbstractSequentialList empty? "+ absSequential.isEmpty()); } }
输出
Elements in the AbstractSequentialList = [] Is the AbstractSequentialList empty? True
广告