The isEmpty() method of AbstractSequentialList in Java


The isEmpty() method of the AbstractSequentialList class is used to check whether the list is empty or not. If it is empty, then TRUE is returned, else FALSE.

The syntax is as follows.

public boolean isEmpty()

To work with the AbstractSequentialList class in Java, you need to import the following package.

import java.util.AbstractSequentialList;

The following is an example to implement AbstractSequentialList isEmpty() method in Java.

Example

 Live Demo

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());
   }
}

Output

Elements in the AbstractSequentialList = [110, 320, 400, 550, 600, 700, 900]
Is the AbstractSequentialList empty? False

Example

 Live Demo

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());
   }
}

Output

Elements in the AbstractSequentialList = []
Is the AbstractSequentialList empty? True

Updated on: 30-Jul-2019

57 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements