The code you provided demonstrates how to retrieve and iterate over the elements of a Vector using the get method and a for loop in Java. Here's a breakdown of what the code does:
import java.util.*; public class GetElements { public static void main(String[] args) { Vector < String > vec_list = new Vector < String > (); int i = 0; vec_list.add("Grapes"); vec_list.add("Banana"); vec_list.add("Apple"); vec_list.add("Cherry"); vec_list.add("Orange"); vec_list.add("Mango"); System.out.println("Vector Elements : "); for (i = 0; i < vec_list.size(); i++) { System.out.println(" " + vec_list.get(i)); } } }
Vector Elements : Grapes Banana Apple Cherry Orange Mango
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions