IT. Expert System.

Java basics

removeAll()


The removeAll(Collection c) is used to remove all the elements of the vector that are contained in the specified Collection.

Syntax:
Library: java.util.Vector

public boolean removeAll(Collection c)


Example:

import java.util.Vector;

public class VectorDemo {
   public static void main(String[] args) {
      // create an empty Vector vec with an initial capacity of 4      
      Vector vec = new Vector(4);

      // use add() method to add elements in the vector
      vec.add(4);
      vec.add(3);
      vec.add(2);
      vec.add(1);

      // let us print all the elements available in vector
      System.out.println("Added numbers are :- "); 
      for (Integer number : vec) {         
         System.out.println("Number = " + number);
      }
      System.out.println("Size of the vector: "+vec.size());
      
      // let us remove all the elements
      System.out.println("Removing all the elements"); 
      vec.removeAll(vec);
      System.out.println("Size of the vector: "+vec.size());       
   }     
}

Output:

Added numbers are :- 
Number = 4
Number = 3
Number = 2
Number = 1
Size of the vector: 4
Removing all the elements
Size of the vector: 0


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 672 / 158776269. Delta: 0.02417 с