Primitive Array - Core Java Type
Collection API - Lists, Sets, Queues
Generics and Typing Interfaces
LISTS
SETS
QUEUE
Collection Framework (Interface/Classes)
Interface
Implementations i.e . Classes
Algorithms
Array | Collection |
---|---|
Fixed size | Dynamic and resizable |
Holds only homogeneous data | Can hold both homogeneous and heterogeneous data |
Less memory-efficient compared to collections | More memory-efficient due to dynamic allocation |
No built-in data structures | Uses built-in data structures and algorithms |
Can store both primitive and object types | Stores only object types |
Collection | Collections |
---|---|
Root interface of Java Collection Framework | Utility class for collection operations |
Implemented by List, Set, and Queue | Provides utility methods like sort() , reverse() , shuffle() , etc. |
A data structure is a way of organizing and storing data efficiently. It not only holds data but also provides operations for accessing, modifying, and managing it.
A container is a class that holds and organizes objects, such as arrays and lists. Containers define both an organizing structure and an interface for interacting with the stored elements.
List
interface.ArrayList
is created.ArrayList
is a concrete class with a default initial capacity of ten.ArrayList
is faster for retrieving data but slower for modifications.
head node
next node
null