- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 AbstractList class in Java?
To add elements to AbstractList class, the add() method is provided by the AbstractList class. The elemnt gets appended at the end of the list.
The syntax is as follows:
public boolean add(E ele)
Here, the parameter ele is an element to be appended to this list
To work with the AbstractList class, import the following package:
import java.util.AbstractList;
The following is an example to add elements to AbstractlList class in Java:
Example
import java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] args) { AbstractList<Integer> myList = new LinkedList<Integer>(); myList.add(50); myList.add(100); myList.add(150); myList.add(200); myList.add(250); myList.add(300); myList.add(350); myList.add(400); System.out.println("Elements in the AbstractList class = " + myList); } }
Output
Elements in the AbstractList class = [50, 100, 150, 200, 250, 300, 350, 400]
- Related Articles
- How to add elements to AbstractCollection class in Java?
- What is AbstractList Class in Java?
- How to add elements to AbstractSequentialList class at a specific position in Java?
- The addAll() method of AbstractList class in Java
- The lastIndexOf() method of AbstractList class in Java
- The subList() method of AbstractList class in Java
- The indexOf() method of AbstractList class in Java
- The equals() method of AbstractList class in Java
- The clear() method of AbstractList class in Java
- The iterator() method of AbstractList class in Java
- The listIterator() method of AbstractList class in Java
- The get() method of AbstractList class in Java
- The set() method of AbstractList class in Java
- The hashCode() method of AbstractList class in Java
- The remove() method of AbstractList class in Java

Advertisements