Chapter 1 Overview of common Java Collection classes and java Overview

Source: Internet
Author: User

Chapter 1 Overview of common Java Collection classes and java Overview

1. The most common collection classes in Java

  • Collection Interface
    • List interface (repeated elements are allowed): ArrayList, rule List, Vector, and Stack
    • Set interface (repeated elements are not allowed,Can be used for deduplication): HashSet, TreeSet
  • Map Interface
    • HashMap
    • TreeMap (sort by key)

2. Seven Points for Collection

  • Create Collection: the constructor. You can understand what the Collection implementation class has done in the constructor method.
  • Add an object to the Collection: add (E) Method -->The implementation method of the Class determines the performance of this method.
  • Delete objects in the Collection: remove (E) Method -->The implementation method of the Class determines the performance of this method.
  • Obtain a single object in the Collection: get (int index) Method -->The implementation method of the Class determines the performance of this method.
  • Traverse objects in the Collection: iterator. In practice, the enhanced for loop is more commonly used for traversing.
  • Determine whether the object exists in the Collection: contain (E) -->The implementation method of the Class determines the performance of this method.
  • Object sorting in Collection: mainly depends on the Sorting Algorithm adopted

The Collection analysis will be based on the above points.

3. Seven Points for Map

  • Map creation: the constructor, master the implementation class of Map in the constructor method.
  • Add a key-value pair to Map: put (Object key, Object value) Method
  • Delete objects in Map: The remove (Object key) Method
  • Get a single Object in Map: get (Object key) Method
  • Determine whether an Object exists in Map: containsKey (Object key)
  • Traverse objects in Map: keySet () and iterator
  • Sorting of objects in Map: mainly depends on the Sorting Algorithm adopted

The Analysis of Map is based on the above points.

Note:

  • Many of the content in this series will refer to distributed Java applications: basics and practices.Lin HaoWritten.
  • The content of this series is based on JDK1.6.45. We recommend that you associate the source code with eclipse.

 

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.