Java FAQ: Top Questions
16. What are Java collections, and what is the Collections Framework?
The
Java Collections Framework
is a set of classes and interfaces in the
java.util
package for storing and manipulating groups of objects (collections).
-
Core Interfaces:
List
(ordered, allows duplicates),Set
(no duplicates),Map
(key-value pairs). -
Implementations:
ArrayList
,LinkedList
(List);HashSet
,TreeSet
(Set);HashMap
,TreeMap
(Map). -
Utilities:
The
Collections
class provides methods likesort
,reverse
, andshuffle
. -
Generics:
Collections use generics for type safety (e.g.,
List
).