Before The Introduction of The
Before The Introduction of The
data structures like arrays and primitive data types (int, float, etc.) for storing and managing
collections of elements.
These basic data structures had limitations, and developers often had to implement their own data
structures and algorithms to work with collections of objects efficiently.
Here are some key points about the state of collections in Java before the introduction of the
collections framework:
1. Arrays: Arrays were the primary data structure for storing collections of elements in early Java
versions.
Arrays have a fixed size and are not dynamic, meaning you need to know the size of the collection at
the time of creation.
2. No Standardized Data Structures: Java did not provide a standardized library for data structures
like lists, sets, or maps.
Developers had to implement these data structures from scratch or use third-party libraries.
3. Lack of Type Safety: Arrays are not type-safe, which means you can store elements of different
types in the same array.
This can lead to runtime errors if you attempt to retrieve an element of the wrong type.
4. No Built-in Algorithms: Java lacked built-in algorithms for common operations on collections, such
as sorting, searching, or iterating.
5. Limited Standard Library: Java had a limited set of data structures and utility classes in its standard
library.
For example, it provided the `Vector` and `Hashtable` classes, but these were considered outdated
and not suitable for modern programming needs.
The introduction of the collections framework in Java 2 (J2SE 1.2) addressed many of these
limitations.
It introduced a comprehensive set of data structures, interfaces, and algorithms for working with
collections of objects.
Key components of the collections framework include `List`, `Set`, `Map`, and various concrete
implementations like `ArrayList`, `HashSet`, and `HashMap`.
These data structures are more versatile, type-safe, and efficient than the earlier alternatives, making
Java a more powerful and flexible language for handling collections of data.
--------------------------------------------------------------------------------
https://www.javatpoint.com/collections-in-java
--------------------------------------------------------------
Collection is the interface where you group objects into a single unit. Collections is a utility class that
has some set of operations you perform on Collection.
Collection does not have all static methods in it, but Collections consist of methods that are all static.
Simple : Collections is a interface conatains static methods for do common operations in child
implementations classes of (Collection Interface)
--------------------- -----------------------------------------------------------
Note:
---------------Arrays accepts primitive data types and non primitive data tyeps Objects homogenous
Array fixed size cannot increase it’s size,but AL increases it’s size
Array:we get runtime ArrayIndex out of bounds Exception but Al increases it’s size
Vector
TreeSet
-----------------------------------------------
Java LL and AL:
List(I)-------AbstratcList(I)------extends ----------LinkedList--------implementsDEques