Java Container Summary

Source: Internet
Author: User
Tags comparable

a picture

three points of knowledge1. iterators
    1. Java.util.iterator+hashnext () Next () Remove ()
    2. Java.lang.iterable+ rewrite iterator () returns an iterator (the container needs to use enhanced for foreach )
2. Comparator
    1. Entity classes can be sorted Java.lang.comparable+compareto
    2. Sort comparer (decoupling, coping with multiple collations) java.util.comparator+ overriding compare () method
      Container sort: list+collections.sort () method
      TreeSet, TreeMap
3. Generic type <>

Generic classes, generic methods, generic interfaces, generic erase, wildcard characters? Extends super, generics nesting

Six InterfacesCollection, Set, List, Map, Iterator, comparable Nine common classes(Add, delete, view + Traverse) 1. ArrayList:

The underlying is an array for viewing redundant modifications @**@

add(E e) 、addindex, E element) 、removeindex) 、remove(Object o) 、setindexindex)遍历:1、for+get  2、foreach  3、Iterator  4、ListIterator
2.LinkedList:

The bottom is the linked list, which is suitable for modifying the redundant view, the method of the chain head and the tail of the chain.

3.HashSet:

Elements cannot be duplicated, so require elements to override the Hashcode and Equals methods

add(E e)remove(Object o) 遍历:1、foreach  2、Iterator
4.TreeSet:

Elements can be sorted or provide a sort of business class

5.HASHMAP:

Key cannot be repeated must override Hashcode+equals method @**@

put(K key, V value)、Remove(Object key)、ContainsKey(Object key)、Containsvalue(Object value)Traversal: Gets the value:Values()、KeySet()+Get()、EntrySet()+GetValue()Get key:KeySet()、EntrySet()+GetKey()Get key and value:KeySet()+Get()、EntrySet()+GetKey()+GetValue()
6.Properties:

Resource profile relative path get file @**@

7.Hashtable:

Both key and value cannot be null thread safe, and the efficiency is relatively low

8.Stack: Stack 9.Collections: Tool class

Java Container Summary

Related Article

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.