java--Collection

Source: Internet
Author: User

Set Features:

1. Element types can vary.

2. The set length is variable.

3. Space is not fixed.

 

In Java, some data structures and algorithms are encapsulated as a collection, which is also an object for storing, retrieving, manipulating, and transmitting objects.

  

JFC (Java Collections Framework) collection framework, which provides interfaces and classes for managing collections

The collection framework consists of three elements: interface, implementation class, algorithm

Interface: Collection is the parent interface for list and set. The list is characterized by: linear, elements can be repeated. Set is characterized by: elements cannot be duplicated.

Map collection: An element contains two objects (key objects and value objects), and keys cannot be duplicated.

The difference between a collection and an array:

1. Only references to objects can be stored in the collection, either as primitive types or as reference types.

2. The length of the collection can vary with the number of elements, and when the array is created, the length cannot change.

3. The collection algorithm is rich, can save a lot of developers coding, but the array algorithm is limited.

How to traverse:

1.for loop traversal, only for the list collection.

2. Iterator method, get the algorithm and interface of the iterator. Iterator

3.for each way

Iterator method to get the iterator algorithm interface

Itertor<student> It=stu.itertor ();

while (It.hasnext) {

Student S=is. Next ();

}

java--Collection

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.