Export (0) Print
Expand All

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:
        lList.clear();
        
        // Check if the list is empty:
        if(lList.isEmpty())
            System.out.println("The list is now empty.");
    }
}

/*
The list is now empty.
*/

Community Additions

ADD
Show:
© 2015 Microsoft