Java Collection Framework Origin

Source: Internet
Author: User
The origin of the Java Collection Framework


before Java2, Java is not a complete set framework, it only has some simple extensible container class, such as vector,stack,hashtable. The Java Collections Framework (JCF) is a general-purpose container. Why the container class exists. a container class can store multiple data, and a Java container class can only hold objects, and the base type (int,long,float,double, etc.) needs to be wrapped into an object type (Integer,long,float, Double, etc.) to be placed in the container. This can result in additional performance and space overhead.


- An array can hold both the base type of data and the object. Why do you also define a container class when an array can store multiple data.

Disadvantages of arrays:
1. Once the array is initialized, its length is fixed.

2. If you need to store more than one data in n places, you should specifically write an array of operations, so that there is no implementation of the dry principle, that is, the code functions repeatedly-damage encapsulation.

3. If everyone uses an array class, the class names and methods defined by different people are different, and the implementation details are uneven. Sun's own definition of tired container class, each developer just call it. What is a collection framework.

Although these container classes are very useful, they cannot be centrally and uniformly managed. A collection framework is a unified, standard architecture for representing and manipulating a set. Any collection framework contains three content:
1. External interface
2. Implementation of the interface
3. The algorithm for set operations (the underlying algorithm that corresponds to a data structure) why need a collection framework (the classes and interfaces for the collection exist in the Java.util toolkit)

1. Provide reuse of code functions
2. Let developers focus on the development of the business, rather than the data structures and algorithms commonly used in the collection class:
1.Set (SET): Objects of a collection are not sorted in a particular way, and elements are not allowed to repeat. Equivalent to a set in mathematics
2.List (list): Objects in the collection are sorted by index, allowing the elements to repeat.
3.Map (map): Each element in the collection contains a pair of key and value objects, and the key object cannot be duplicated, but the value object can be duplicated.

This article is based on online pony video summary.

Thanks for reading.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.