- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
The get() method of Java AbstractSequentialList class
The get() method of the AbstractSequentialList class is used to display the element at the specified position in this list.
The syntax is as follows
public E get(int index)
Here, index is the location from where you want to get the element.
To work with the AbstractSequentialList class in Java, you need to import the following package
import java.util.AbstractSequentialList;
The following is an example to implement AbstractSequentialList get() method in Java
Example
import java.util.LinkedList; import java.util.AbstractSequentialList; public class Demo { public static void main(String[] args) { AbstractSequentialList<Integer> absSequential = new LinkedList<>(); absSequential.add(10); absSequential.add(25); absSequential.add(60); absSequential.add(70); absSequential.add(195); System.out.println("Elements in the AbstractSequentialList = "+absSequential); System.out.println("Element at index 2 = " + absSequential.get(2)); System.out.println("Element at index 4 = " + absSequential.get(4)); } }
Output
Elements in the AbstractSequentialList = [10, 25, 60, 70, 195] Element at index 2 = 60 Element at index 4 = 195
Advertisements