JAVA Foundation--java API Collection Framework (ArrayList, HashSet, HashMap use)

Source: Internet
Author: User

first, set collection1. Introduction to the collection

Variable: Represents a space in memory that can only hold individual data of a certain type

Array: represents multiple contiguous spaces in memory that can store multiple data of the same type.

Later in the process of learning object-oriented technology, we began to create objects in the program, using objects. When more and more are created in the program, we need to store these objects as well.

Need to store object: Must be a container.

Variable: Yes, requires that the variable must be a reference variable, but only a single object can be stored

Array: Yes, but it requires that the number of objects stored is fixed.

String buffer: No, because the data in it will eventually be converted to a string.

Another class of containers is available in Java: The collection, which is specifically responsible for storing objects in the program.

The three most frequently used collection objects in development:

ArrayList:

HashSet:

HASHMAP:

A collection is a class container: It also has the most basic way to operate a container:

increase, delete, change, check, judge, traverse.

There are many collections containers designed in Java that can store objects, but when objects are stored in those containers, the container handles the objects differently.

The focus of the learning set is to know how the underlying objects in each collection are handled. Know the underlying data structure for each collection.

Because the collection container is too many, the programmer needs to know how each collection handles itself, not easy to remember and use. So Java and the common operation of these collection containers to extract and summarize, and finally give us a set of all the set of containers should have the basic operating mode.

Java defines the collection interface, which defines the operational rules for the commonality of all collections. All the collection containers in Java are implemented according to the rules defined in collection, and we can easily manipulate each collection container as long as the rules defined in the collection interface are in development.

2.Collection Interface Introduction

     

Collection The root interface in the hierarchy . Collection represents a set of objects, also known as Collection elements . Some collection allow duplicate elements, while others do not. Some of the collection are orderly, while others are unordered. The JDK does not provide any direct implementation of this interface: it provides more specific sub-interfaces (such as Set and List) implementations. This interface is often used to pass collection and operate these collection where it is required to be the most universal.

Collection it is the top-level interface in a collection system. There are multiple collection container objects under it, some of which can hold duplicate objects, some cannot, some can guarantee the order of stored data, and some cannot be guaranteed.

The collection interface defines the most shared operation mode for the collection.

3. Introduction to Methods in collection

JAVA Foundation--java API Collection Framework (ArrayList, HashSet, HashMap use)

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.