Java Fundamentals: Collection Summary

Source: Internet
Author: User

First, set concept

I believe we all know that Java is an object-oriented programming language, and the embodiment of things are in the form of objects, so in order to facilitate the operation of multiple objects, the object is stored for storage, collection is the most common way to store objects, we can think of the set as a container.

Similarly, an array is also a container, so what is the difference between a collection and it?

1. Arrays can also store objects, but the length is fixed, and the set length is variable.
2. The base data type data can be stored in an array, and the collection can store only objects.
3. The basic data type data or objects stored in the array are of the same type, and the collection can store different types of objects.

Therefore, a collection class is required when you do not know the number of data to be stored beforehand, or if you need a method that is more flexible than the array subscript access mechanism .

Java Fundamentals: Collection Summary

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.