Copier Vecteur dans un Vecteur
Bonjour,
Mon code est le suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
import java.util.Collections;
import java.util.Vector;
public class CopyElementsOfVectorToVectorExample {
public static void main(String[] args) {
//create first Vector object
Vector v1 = new Vector();
//Add elements to Vector
v1.add("1");
v1.add("2");
v1.add("3");
//create another Vector object
Vector v2 = new Vector();
Collections.copy(v2,v1);
System.out.println("After copy, Second Vector Contains : " + v2);
}} |
Mais j'ai eu l'erreur suivante:
Citation:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Source does not fit in dest
at java.util.Collections.copy(Collections.java:548)
at CopyElementsOfVectorToVectorExample.main(CopyElementsOfVectorToVectorExample.java:20)
Avez-vous une idée ?
Merci.