VOOZH about

URL: https://www.geeksforgeeks.org/java/vector-elementat-method-in-java/

⇱ Java Vector elementAt() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Vector elementAt() Method

Last Updated : 11 Jul, 2025

In Java, the elementAt() method is used to fetch or retrieve an element at a specific index from a Vector. It allows to access elements in the vector by providing the index, which is zero-based.

Example 1: Here, we use the elementAt() method to retrieve an element at a specified index with an Integer type.


Output
 [10, 20, 30, 40, 50]
 The element is: 40

Syntax of Vector element() Method

public E elementAt(int index)

  • Parameter: index: It specifies the position of the element we want to retrieve.
  • Return Type: It returns the element present at the position specified.

Example 2: Here, we use the elementAt() method to retrieve an element at a specified index with String type.


Output
 [Geeks, for, Geeks]
 The element is: for
Comment