This example shows how to remove all elements from Vector at once. You can call the method clear() to remove all values from Vector with a single call.
import java.util.Vector;Runtime:
public class Clear_vector {
public static void main(String[] args) {
Vector< String>vct = new Vector< String> ();
//add elements
vct.add("un");
vct.add("two");
vct.add("three");
vct.add("four");
System.out.println("Before deletion:");
for(String e:vct)
System.out.println(e);
System.out.println("\nAfter deletion:");
vct.clear();
for(String e:vct)
System.out.println(e);
}
}
Before deletion:
one
two
three
four
After deletion:
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...