Click here to watch in Youtube :
https://www.youtube.com/watch?v=4ZMl-P3AQ4w&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
Output
https://www.youtube.com/watch?v=4ZMl-P3AQ4w&list=UUhwKlOVR041tngjerWxVccw
VectorExample.java
import java.util.Vector; /* * Example of clone() method */ public class VectorExample { public static void main( String[] args ) { Vector<Integer> vector = new Vector<Integer>(); vector.add(10); vector.add(20); vector.add(30); System.out.println("vector : " + vector); /* * Returns a clone of this vector. The copy will contain a reference to * a clone of the internal data array, not a reference to the original * internal data array of this Vector object. */ Object object = vector.clone(); Vector<Integer> clonedVector = (Vector<Integer>) object; System.out.println("clonedVector : " + clonedVector); } }
vector : [10, 20, 30] clonedVector : [10, 20, 30]
https://sites.google.com/site/javaee4321/java-collections/VectorDemoClone.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment