ITWissen.info - Tech know how online

collections framework

The Java Collections framework is a hierarchically organized set of collections. These are also called containers and characterize data structures that integrate a group of data into one unit. The data - as well as the objects - of the collections are also called elements, whereby these may be accessed only with the appropriate methods. With regard to the storage and management of large amounts of data, the Collections framework provides extensive functionalities and application possibilities. Starting from the version 1.5 of Java (Java 5) the Collections support also generic data types.

The design of the collections framework

The design of the Collections framework defines a hierarchy of interfaces that are provided in the java.util package for managing the data structures. The different interfaces each support different data structures. An interface provides only the interface for accessing a data structure. How the data is finally stored, is determined by the concrete implementation of the interface. In each case several classes implement these interfaces.

Interfaces of the Collections Framework

Interfaces of the Collections Framework

The illustration clarifies the basic structure of the Collections framework with some interfaces. The names of the classes contain the name of the implemented interface. For example, the class ArrayList implements the interface List. Thus the appropriate basic type is to be assigned at the name of the class.

While the interfaces List, Set and Queue are derived from the base interface Collection, the interface Map stands autonomously at the top of the hierarchy. The following is a brief description of the interfaces:

Collection Basic interface that provides basic operations (methods) for working with collections.

List Supports arbitrarily large lists of elements of different types, which can be accessed sequentially or randomly.

Set A set of elements that can be accessed with appropriate operations.

Queue List often used as a queue that can only be accessed sequentially (e.g., First In First Out). Random access is not allowed.

Deque Deque (double ended queue) describes a special form of queue that allows elements to be added or removed both at the beginning and at the end.

Map Used to implement key-value pairs, i.e. a set of related object pairs.

Since collections are not synchronized, inconsistent data and program errors may occur if several simultaneously executed program modules(threads) access the same collection. Access to the collection is the responsibility of the software development.

The Collections framework provides a comprehensive library of functionalities for storing and managing large amounts of data. The flexible interface for the design when passing Collection objects is made possible by their inheritance hierarchy. With reference to the basic Collection interface, concrete data structures can be easily changed without having to change the operating method as well.

Informations:
Englisch: collections framework
Updated at: 04.11.2013
#Words: 447
Links: Java, framework, data, unit (U), application (app)
Translations: DE
Sharing:    

All rights reserved DATACOM Buchverlag GmbH © 2024