Collection Interface isEmpty() Method

Collection Interface isEmpty() Method


Posted in : Java Posted on : November 27, 2010 at 11:19 AM Comments : [ 0 ]

� Using this method we can find out the invoking collection is empty or not. It returns true if the invoking collection is empty. Otherwise, returns false.

Collection Interface isEmpty() Method:

 Using this method we can find out the invoking collection is empty or not. It returns true if the invoking collection is empty. Otherwise, returns false.

Syntax :

boolean isEmpty( );

Example :

import java.util.ArrayList;
import java.util.Collection;

public class CollectionInterfaceisEmptyMethod {

public static void main(String[] args) {
Collection collection = new ArrayList(); 
collection.add("Deepak");
collection.add("Kumar");

boolean result = collection.isEmpty();
if(result==true){
System.out.println("ArrayList is empty."); 
}
else{
System.out.println("ArrayList is not empty.");
} 
}
}

Output :

ArrayList is not empty.

Download This example code

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics