Collection Interface removeAll() Method

Collection Interface removeAll() Method


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

Using this method we can removes all elements from the invoking collection.

Collection Interface removeAll() Method:

Using this method we can removes all elements from the invoking collection. It returns true if all elements of the invoking collection was removed. Otherwise, returns false.

Syntax :

boolean removeAll(Collection c);

Example :

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

public class CollectionInterfaceRemoveAllMethod {

public static void main(String[] args) {
  Collection collection = new ArrayList();
  collection.add("India");
  collection.add("Shrilanka");
  collection.add("Pakistan");
    
  boolean result = collection.removeAll(collection);  
  if(result==true){
	  System.out.print("All Elements Remove.");		      
  }
  else{
	  System.out.print("All Elements Not Remove.");
  }	      	      
 }
}

Output :

All Elements Remove.

Download This example code

Go to Topic «PreviousHomeNext»

Your Comment:


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

 
Tutorial Topics