Home > Java > javaTutorial > Collections framework overview

Collections framework overview

高洛峰
Release: 2016-11-18 10:19:13
Original
1401 people have browsed it

The role of the collection framework

In actual development, we often perform unified management operations on a set of the same type of data. So far, we can use arrays, linked list structures, and binary tree structures to achieve this.

The biggest problem with arrays is that the number of elements in the array is fixed. To implement a dynamic array, comparison is still troublesome. It is even more inconvenient to implement a linked list or binary tree structure to manage objects by yourself.

After JDK1.2, JAVA fully provides the concept of class collections and encapsulates a set of powerful and very convenient collection framework APIs, which greatly improves our efficiency in development.

Collections are divided into three major interfaces

Collection (collection), Map (mapping), Iterator (iteration, convenience)

The interfaces and classes of the collection framework are in the Java.util package

Collection framework structure diagram

Collections framework overview

Collection interface


1. The root interface in the Collection hierarchy. Collection represents a set of objects, which are also called elements of the collection. Some collections are ordered, while others are unordered,


Some collections allow duplicate elements, while others do not. The JDK does not provide any direct implementation of this interface: it provides implementations of more specific sub-interfaces such as Set and List.


2. Definition of interface

public interface Collection

extends Iterable


3.Collection provides an interface for some common operations on collections, including

insert add()

Delete remove()

Judge whether an element is its member contains()

Traverse iterator()


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template