vector class removeAllElements () método : Aquí, vamos a aprender acerca de los removeAllElements método () de Vector Class con su sintaxis y su ejemplo.
removeAllElements Vector Class () método método
- removeAllElements () está disponible en java.util Class.
- removeAllElements () método se utiliza para eliminar todos los elementos existentes de este vector.
- removeAllElements () método es un método no class, es accesible sólo con el objeto package y si tratamos de acceder al método con el nombre static entonces obtendrá un error.
- removeAllElements () método no class una excepción en los elementos de la eliminación.
Sintaxis:
public boolean removeAll(Collection co);
Parámetro (s):
No acepta cualquier parámetro.
class valor:
El tipo throw del método es throw , no devuelve nada.
Ejemplo:
// Java program to demonstrate the example
// of boolean removeAll(Collection co)
// method of Vector
import java.util.*;
public class RemoveAllOfVector {
public static void main(String[] args) {
// Instantiates a Vector object with
// initial capacity of "10"
Vector < String > v = new Vector < String > (10);
ArrayList arr_l = new ArrayList();
// By using add() method is to add the
// elements in this v
v.add("C");
v.add("C++");
v.add("JAVA");
// By using add() method is to add the
// elements in this arr_l
arr_l.add("C");
arr_l.add("C++");
arr_l.add("SFDC");
// Display Vector and ArrayList
System.out.println("v: " + v);
System.out.println("arr_l: " + arr_l);
// By using removeAll(arr_l) method is to
// remove all elements of this vector v that
// exists in the given collection arr_l
v.removeAll(arr_l);
// Display updated Vector
System.out.println("v.removeAll(arr_l): " + v);
}
}
salida
v: [C, C++, JAVA]
arr_l: [C, C++, SFDC]
v.removeAll(arr_l): [JAVA]