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. |

[ 0 ] Comments