![]() |
VOOZH | about |
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.
[10, 20, 30, 40, 50] The element is: 40
public E elementAt(int index)
Example 2: Here, we use the elementAt() method to retrieve an element at a specified index with String type.
[Geeks, for, Geeks] The element is: for