- Trending Categories
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
How to add elements to AbstractSequentialList class at a specific position in Java?
The AbstractSequentialList class has the add() method to add an element to the specific position.
The syntax is as follows
add(int index, E ele)
Here, index is where the element is to be inserted. The ele is the element to be inserted.
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 add() 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(0, 50); absSequential.add(1, 30); absSequential.add(2, 80); absSequential.add(3, 150); absSequential.add(4, 110); absSequential.add(5, 200); absSequential.add(6, 350); System.out.println("Elements in the AbstractSequentialList = "+absSequential); } }
Output
Elements in the AbstractSequentialList = [50, 30, 80, 150, 110, 200, 350]
- Related Articles
- The add() method of Java AbstractSequentialList class
- How to add columns at specific position in existing table in MySQL?
- How to add elements to AbstractCollection class in Java?
- How to add elements to AbstractList class in Java?
- How to insert an object in an ArrayList at a specific position in java?
- What is AbstractSequentialList class in Java?
- Add a character to a specific position in a string using Python
- Golang program to add elements at first and last position of linked list
- How do I insert elements at a specific index in Java list?
- How to add components with a Relative X Position in Java
- The listIterator() method AbstractList class in Java at a specified position
- The listIterator() method of Java AbstractSequentialList class
- The remove() method of Java AbstractSequentialList class
- The get() method of Java AbstractSequentialList class
- The set() method of Java AbstractSequentialList class

Advertisements