Java List get() Method24 Mar 2025 | 2 min read The get() method of List interface returns the element at the specified position in this list. SyntaxParametersThe parameter 'index' represents the index of the elements to return. ReturnThe get() method returns the element at the specified position in this list. Throws:IndexOutOfBoundsException- If the index is out of range i.e. index<0 or index>=size(). Example 1Output: Element 0 stored at Index : 0 Element 1 stored at Index : 1 Element 2 stored at Index : 2 Element 3 stored at Index : 3 Element 4 stored at Index : 4 Element 5 stored at Index : 5 Example 2Output: ID : 17 Name :Ajeet Kumar Age : 36 Example 3Output: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: -1, Size: 3 atjava.util.LinkedList.checkElementIndex(LinkedList.java:555) atjava.util.LinkedList.get(LinkedList.java:476) at com.tpointtech.JavaListGetExample3.main(JavaListGetExample3.java:12) Next TopicJava List |
We request you to subscribe our newsletter for upcoming updates.

We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India