Interview questions organize notes series one Java container class

Source: Internet
Author: User

The dashed box represents the interface, the solid wireframe represents the entity class, The thick wireframe represents the most commonly used entity classes, the dashed arrows indicate the implementation of the interface, and the implementation arrows indicate that the class can make objects of the class that the arrows refer to.

  1. Collection: Allows only one object to be placed in each location. It includes a list of "holding a set of objects in a certain order", and a set that "only allowed to add non-repeating objects." You can add elements to the collection object using the Add () method.
  2. Map: A group of pair,map that appear in the form of "key key-value" also does not accept duplicate key values. You can use the put () method to add elements to a map.

The difference between collection and Collecitons: Collections is the class under Java.util, it contains a variety of static methods related to the operation of the collection, to achieve a variety of combinations of search, sequencing, thread security and other operations. Collection is the interface under Java.util, which is the parent interface of various collection structures. The interfaces that inherit from it are mainly set and list.

Regardless of which set you use, you need to define the Equals () method, but you need to define HASHCODE () only if you want to put the object in HashSet. Because HashSet is the set we usually use, we usually also need to define HASHCODE (). As a programming style, the hashcode () should also be covered while the Equals () is being written.

Interview questions organize notes series one Java container class

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.