AbstractSequentialList get() method in Java with Examples
The get() method of AbstractSequentialList is used to fetch or retrieve an element at a specific index from a AbstractSequentialList.
Syntax:
AbstractSequentialList.get(int index)
Parameters: The parameter index is of integer data type that specifies the position or index of the element to be fetched from the AbstractSequentialList.
Return Value: The method returns the element present at the position specified by the parameter index.
Below programs illustrate the Java.util.AbstractSequentialList.get() method:
Example 1:
// Java code to illustrate get() method import java.util.*; import java.util.AbstractSequentialList; public class AbstractSequentialListDemo { public static void main(String args[]) { // Creating an empty AbstractSequentialList AbstractSequentialList<String> absqlist = new LinkedList<String>(); // Use add() method to add elements absqlist.add("Geeks"); absqlist.add("for"); absqlist.add("Geeks"); absqlist.add("10"); absqlist.add("20"); // Displaying the list System.out.println("AbstractSequentialList:" + absqlist); // Fetching the specific element from the list System.out.println("The element is: " + absqlist.get(2)); } } |
AbstractSequentialList:[Geeks, for, Geeks, 10, 20] The element is: Geeks
Example 2:
// Java code to illustrate get() method import java.util.*; import java.util.AbstractSequentialList; public class AbstractSequentialListDemo { public static void main(String args[]) { // Creating an empty AbstractSequentialList AbstractSequentialList<Integer> absqlist = new LinkedList<Integer>(); // Use add() method to add elements absqlist.add(1); absqlist.add(2); absqlist.add(3); absqlist.add(4); absqlist.add(5); // Displaying the list System.out.println("AbstractSequentialList:" + absqlist); // Fetching the specific element from the list System.out.println("The element is: " + absqlist.get(4)); } } |
AbstractSequentialList:[1, 2, 3, 4, 5] The element is: 5
Recommended Posts:
- AbstractSequentialList set() method in Java with Examples
- AbstractSequentialList remove() method in Java with Examples
- AbstractSequentialList addAll() Method in Java with Examples
- AbstractSequentialList in Java with Examples
- AbstractSequentialList contains() method in Java with Example
- AbstractSequentialList toString() method in Java with Example
- AbstractSequentialList toArray() method in Java with Example
- AbstractSequentialList retainAll() method in Java with Example
- AbstractSequentialList size() method in Java with Example
- AbstractSequentialList conatinsAll() method in Java with Example
- AbstractSequentialList removeAll() method in Java with Example
- AbstractSequentialList indexOf() method in Java with Example
- AbstractSequentialList clear() method in Java with Example
- AbstractSequentialList isEmpty() method in Java with Example
- AbstractSequentialList equals() method in Java with Example
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



