A collection framework for the reinforcement of Java Fundamentals Note 01: The origin of the collection differs from the array

Source: Internet
Author: User

1. The origin of the collection:

We are learning object-oriented language, and object-oriented language is the description of things through objects, in order to facilitate the operation of multiple objects, we have to store these multiple objects. To store multiple objects, you cannot be a basic variable, but rather a variable of a container type, what are the container types in the knowledge we have learned? Arrays and StringBuffer. But what? The result of StringBuffer is a string that does not necessarily meet our requirements, so we can only select an array, which is an array of objects . And the object array does not adapt to the needs of change, because the length of the array is fixed , this time, in order to adapt to the needs of change,Java provides a collection of classes for us to use .

2. The difference between a set and an array

(1) Length difference:
Fixed length of array
Variable Set length
(2) Different contents:
Arrays store elements of the same type
Collections can store different types of elements
(3) The data type problem of the element:
Arrays can store basic data types, or they can store reference data types
Collection can only store reference types

3. Features of the collection class

A: The collection is used only for storing objects, the collection length is mutable, and the collection can store different types of objects.

A collection framework for the reinforcement of Java Fundamentals Note 01: The origin of the collection differs from the array

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.