Java ArrayList isEmpty Example
ArrayList class isEmpty method example. This example shows you how to use isEmpty method.
ArrayList class isEmpty method example.public boolean isEmpty() Returns true if this list contains no elements.
Here is the code
/**
* @ # isEmpty.java
* A class repersenting use to isEmpty method of ArrayList class in java.util package
* version 14 May 2008
* author Rose India
*/
import java.util.*;
public class IsEmpty {
public static void main(String args[]) {
List arrlist = new ArrayList();
int i = 0;
String str = "Rose";
System.out.println("Arraylist is empty "+arrlist.isEmpty());
//Add the specified element to the end of this list.
arrlist.add(i);
arrlist.add(str);
arrlist.add("India");
System.out.println("arrlist = "+arrlist);
System.out.println("Arraylist is empty "+arrlist.isEmpty());
}
public IsEmpty() {
}
}
|
Output
Arraylist is empty true
arrlist = [0, Rose, India]
Arraylist is empty false |
|