- 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 AbstractCollection class in Java?
To add elements to the AbstractCollection class, use the add() method. For example −
absCollection.add("These"); absCollection.add("are"); absCollection.add("demo");
To work with AbstractCollection class in Java, import the following package −
import java.util.AbstractCollection;
The following is an example to add elements to AbstractCollection class in Java −
Example
import java.util.ArrayList; import java.util.AbstractCollection; public class Demo { public static void main(String[] args) { AbstractCollection<Object> absCollection = new ArrayList<Object>(); absCollection.add("These"); absCollection.add("are"); absCollection.add("demo"); absCollection.add("elements"); System.out.println("Displaying elements in the AbstractCollection: " + absCollection); } }
Output
Displaying elements in the AbstractCollection: [These, are, demo, elements]
- Related Articles
- How to add elements to AbstractList class in Java?
- What is AbstractCollection class in Java?
- How to add elements to AbstractSequentialList class at a specific position in Java?
- The containsAll() method of Java AbstractCollection class
- The isEmpty() method of Java AbstractCollection class
- The iterator() method of Java AbstractCollection class
- The toArray() method of Java AbstractCollection class
- The toString() method of Java AbstractCollection class
- The remove() method of Java AbstractCollection class
- The size() method of Java AbstractCollection class
- The addAll() method of Java AbstractCollection class
- The clear() method of Java AbstractCollection class
- The contains() method of Java AbstractCollection class
- How to add elements in Java CopyOnWriteArrayList?
- How to add elements in Java ArrayBlockingQueue?

Advertisements