The code you provided demonstrates how to iterate over the elements of a Vector using an Iterator in Java. Here's a breakdown of what the code does:
import java.util.*; public class Iterator_Vector { public static void main(String[] args) { Vector < String > vec_list = new Vector < String > (); vec_list.add("Red"); vec_list.add("Green"); vec_list.add("Blue"); vec_list.add("Yellow"); vec_list.add("Orange"); Iterator itr = vec_list.iterator(); System.out.println("Vector Elements are : "); while (itr.hasNext()) { System.out.println(itr.next()); } } }
Vector Elements are : Red Green Blue Yellow Orange
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions