Java Program to Create a Clone of a Vector Collection

You are currently viewing Java Program to Create a Clone of a Vector Collection

Java program to create a clone of a Vector collection

// Java program to create a clone of a 
// Vector collection

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Vector vec = new Vector();

    vec.add(10);
    vec.add(20.5);
    vec.add(true);
    vec.add("Hello World");

    Vector clone = (Vector) vec.clone();

    System.out.println("Vector vec   : " + vec);
    System.out.println("Vector clone : " + clone);
  }
}

Output

Vector vec   : [10, 20.5, true, Hello World]
Vector clone : [10, 20.5, true, Hello World]

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply