![]() |
VOOZH | about |
In Java, the get() method of LinkedList is used to fetch or retrieve an element at a specific index from a LinkedList.
Example 1: Here, we use the get() method to retrieve an element at a specified index.
[Geeks, for, Geeks, 10] The element at index 3 is: 10
public E get(int index)
Example 2: Here, the get() method throw an exception IndexOutOfBoundsException, if we try to retrieve the element at an Invalid Index.
Error: IndexOutOfBounds