This documentation is archived and is not being maintained.

List.isEmpty Method

Visual Studio 2005

Checks if a List object is empty.

Package: java.util

Assembly: vjslib (in vjslib.dll)

public abstract boolean isEmpty();

true if the List object is empty; false otherwise.

In this example, you create and initialize a linked list object, clear it, and then you check to see if the list is empty.

// list-isEmp1.jsl
// List.isEmpty example

import java.util.*;

public class MyClass
    public static void main(String[] args)
        // Create a linked list object:
        LinkedList lList =  new LinkedList();

        // Add some elements:
        lList.add("My node");
        lList.add("Her node");
        lList.add("Their node");
        lList.add("Your node");

        // Clear the list:
        // Check if the list is empty:
            System.out.println("The list is now empty.");

The list is now empty.