0% found this document useful (0 votes)
31 views4 pages

Before The Introduction of The

Before Java introduced the collections framework, it only provided basic data structures like arrays and primitive data types for storing collections. These had limitations as arrays have a fixed size and Java lacked standardized and type-safe data structure implementations. Developers had to write their own collection classes and algorithms. The collections framework addressed these issues by introducing interfaces like List, Set and Map along with common implementations like ArrayList, HashSet and HashMap. These provide more versatile, type-safe and efficient collection handling capabilities to Java.

Uploaded by

venkatesh kilari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views4 pages

Before The Introduction of The

Before Java introduced the collections framework, it only provided basic data structures like arrays and primitive data types for storing collections. These had limitations as arrays have a fixed size and Java lacked standardized and type-safe data structure implementations. Developers had to write their own collection classes and algorithms. The collections framework addressed these issues by introducing interfaces like List, Set and Map along with common implementations like ArrayList, HashSet and HashMap. These provide more versatile, type-safe and efficient collection handling capabilities to Java.

Uploaded by

venkatesh kilari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Before the introduction of the `java.

util` collections framework in Java, early versions of the Java


programming language provided basic

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.

This limitation made it challenging to work with variable-sized collections.

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.

Developers had to write their own algorithms for these tasks.

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.

what is Collections in Java ?

--------------------------------------------------------------------------------

https://www.javatpoint.com/collections-in-java

diff between collection and collections Interface?

--------------------------------------------------------------

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

ArrayList----ArrayList accepts Entities(user defined Objects) Also

Why not array why collection?


--------------------------------------------------------

array fixed size and homogeneous elements are allowed

Arrays and ArrayList :

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

ArrayList & Vector


AL:

Vector

Diff ArrayList And LinkedList

TreeSet

-----------------------------------------------
Java LL and AL:

List(I)-------AbstratcList(I)------extends ----------LinkedList--------implementsDEques

1) ArrayList internally uses a dynamic array to store the elements.


2) LinkedList internally uses a doubly linked list to store the elements.

You might also like