The code you provided demonstrates how to copy elements from a Vector into an array in Java using the copyInto method. Here's a breakdown of what the code does:
import java.util.*; public class Copy_Elements { public static void main(String[] args) { Vector < String > vec_list = new Vector < String > (); String vehicles[] = new String[5]; vec_list.add("Apple"); vec_list.add("Banana"); vec_list.add("Cherry"); vec_list.add("Orange"); vec_list.add("Mango"); System.out.println("Vector Elements : " + vec_list); vec_list.copyInto(vehicles); System.out.println("Array Elements : "); for (String v: vehicles) { System.out.println(" " + v); } } }
Vector Elements : [Apple, Banana, Cherry, Orange, Mango] Array Elements : Apple Banana Cherry Orange Mango
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions