AbstractList get() method in Java with Examples Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The get() method of java.util.AbstractList class is used to return the element at the specified position in this list. Syntax: public abstract E get(int index) Parameters: This method takes index of the element as a parameter, the element at which is to be returned. Returns Value: This method returns the element at the specified position in this list. Exception: This method throws IndexOutOfBoundsException if the index is out of range (index = size()). Below are the examples to illustrate the get() method. Example 1: Java // Java program to demonstrate // get() method // for Integer value import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // Creating object of AbstractList<Integer> AbstractList<Integer> arrlist1 = new ArrayList<Integer>(); // Populating arrlist1 arrlist1.add(10); arrlist1.add(20); arrlist1.add(30); arrlist1.add(40); arrlist1.add(50); // print arrlist1 System.out.println("ArrayListlist : " + arrlist1); // getting the value at the index 3 // using get() method int value = arrlist1.get(3); // print the value System.out.println("Element at index 3 : " + value); } catch (IndexOutOfBoundsException e) { System.out.println("Exception thrown : " + e); } } } Output: ArrayListlist : [10, 20, 30, 40, 50] Element at index 3 : 40 Example 2: Java // Java program to demonstrate // get() method // for IndexOutOfBoundsException import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // Creating object of AbstractList<Integer> AbstractList<Integer> arrlist1 = new ArrayList<Integer>(); // Populating arrlist1 arrlist1.add(10); arrlist1.add(20); arrlist1.add(30); arrlist1.add(40); arrlist1.add(50); // print arrlist1 System.out.println("ArrayListlist : " + arrlist1); // getting the value at the index 7 // using get() method System.out.println("\nTrying to get " + "the element from out" + " of range index "); int value = arrlist1.get(7); // print the value System.out.println("Element at index 7 : " + value); } catch (IndexOutOfBoundsException e) { System.out.println("Exception thrown : " + e); } } } Output: ArrayListlist : [10, 20, 30, 40, 50] Trying to get the element from out of range index Exception thrown : java.lang.IndexOutOfBoundsException: Index: 7, Size: 5 Comment R rohitprasad3 Follow Improve R rohitprasad3 Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-AbstractList +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors10 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java5 min readJava Comparator Interface6 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like