Example
Verify whether a list is devoid of elements.
import java.util.ArrayList;
public class Main {
public static void main(String[] args ) {
ArrayList<String> cars = new ArrayList<String>();
System.out .println(cars .isEmpty());
cars .add("Volvo");
cars .add("BMW");
cars .add("Ford");
cars .add("Mazda");
System.out .println(cars .isEmpty());
}
}
|
Definition and Usage
The isEmpty() method yields true if a list contains no items, and false otherwise.
Syntax
Technical Details
Returns:
|
True if the list contains no items, otherwise false.
|