The code you provided demonstrates how to retrieve the last element of a Vector using the lastElement method in Java. Here's a breakdown of what the code does:
import java.util.*; public class GetLast_Elements { public static void main(String[] args) { Vector < String > vec_list = new Vector < String > (); vec_list.add("Papaya"); vec_list.add("Apple"); vec_list.add("Grapes"); vec_list.add("Cherry"); vec_list.add("Orange"); vec_list.add("Banana"); System.out.println("Last Element: " + vec_list.lastElement()); } }
Last Element: Banana
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions