The Java Platform Java Runtime Environment Data Types Control Statemets Methods Arrays Classes and Objects Inheritance Constructor Interface Packages & Access Modifiers Java Collections Framework![]() What are Collections![]() The Java Collections Framework![]() Benefits![]() Collection hierarchy![]() The Collection Interface![]() Types of Collection![]() Iterators![]() Using Set![]() Using Map![]() Example | The Collection InterfaceA Collection represents a group of objects, known as its elements. Some Collection implementations allow duplicate elements and others do not. Some are ordered and others unordered. public interface Collection {
// Basic Operations
int size();
boolean isEmpty();
boolean contains(Object element);
boolean add(Object element); // Optional
boolean remove(Object element); // Optional
Iterator iterator();
// Bulk Operations
boolean containsAll(Collection c);
boolean addAll(Collection c); // Optional
boolean removeAll(Collection c); // Optional
boolean retainAll(Collection c); // Optional
void clear(); // Optional
// Array Operations
Object[] toArray();
Object[] toArray(Object a[]);
} |