Related Examples
  1. Vector class toString() method example
  2. Vector class toArray() method example
  3. Vector class subList(int fromIndex, int toIndex) method example
  4. Vector class size() method example
  5. Vector class setSize(int newSize) method example
  6. Vector class setElementAt(E obj, int index) method example
  7. Vector class set(int index, E element) method example
  8. Vector class retainAll(Collection c) method example
  9. Vector class removeElementAt(int index) method example
  10. Vector class removeElement(Object obj) method example
  11. Vector class removeAllElements() method example
  12. Vector class removeAll(Collection c) method example
  13. Vector class remove(Object o)method example
  14. Vector class remove(int index) method example
  15. Vector class lastIndexOf(Object o)method example
  16. Vector class lastElement() method example
  17. Vector class isEmpty()method example
  18. Vector class insertElementAt(E obj, int index)method example
  19. Vector class indexOf(Object o, int index)method example
  20. Vector class indexOf(Object o)method example
  21. Vector class hashCode()method example
  22. Vector class get(int index)method example
  23. Vector class firstElement()method example
  24. Vector class equals(Object o) method example
  25. Vector class ensureCapacity(int minCapacity)method example
  26. Vector class elements() method example
  27. Vector class copyInto(Object[] anArray)method example
  28. Vector class containsAll(Collection c)method example
  29. Vector class contains(Object o)method example
  30. Vector class clone()method example
  31. Vector class clear()method example
  32. Vector class capacity()method example
  33. Vector class addElement(E obj)method example
  34. Vector class addAll(int index, Collection c)method example
  35. Vector class addAll(Collection c)method example
  36. Vector class add(int index, E element) method example
  37. Vector class add(E e)method example
  38. Vector class trimToSize() method example
  39. Java Class Vector, Java Vector Methods, Java Vector Functions,Vector Examples Java

View All Examples
 

Vector class addAll(Collection c)method example

Appends all of the elements in the specified Collection to the end of this Vector


Vector class addAll(Collection c)method example.This example shows you how to use addAll(Collection c)method.This method Appends all of the elements in the specified Collection to the end of this Vector

Here is the code:-
/* 
* @Program that  Appends all of the elements in the specified Collection to the
 end of this Vector
 * AddAll.java 
 * Author:-RoseIndia Team
 * Date:-24-May-2008
 */
import java.util.*;
public class AddAll {
public static void main(String[] args) {
//Constructs a LinkedList 
LinkedList l=new LinkedList();
l.add("girish");
l.add("Komal");
l.add("Janoti");
//Creating a Vector containing the same elements as the LinkedList.
Vector V=new Vector();
System.out.println("Vector before adding Elements is :"+V);
//Appends all of the elements in the specified Collection to the end of this 
//Vector
V.addAll(l);
//Constructs a Enumeration Interface
Enumeration e=V.elements();
System.out.print("Vector after adding all the element of linkedlist is :");
 while (e.hasMoreElements())
        {
            System.out.print(e.nextElement()+"\t");
    }
    }
    }

Output of the program:-
Vector before adding Elements is :[]
Vector after adding all the element of linkedlist is :girish    Komal    Janoti   

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US