Knowledge of the Java container class

Source: Internet
Author: User

It novice, especially it programming self-learning novice, also can not tell the meaning of Java each noun, which for learning Java will be a big obstacle. Here is a small part of the summary: knowledge of the Java container class

1. Array and Arrays:arrays: The tool class used to manipulate the array, which contains a set of static functions: Equals (): Compares two arrays for equality. Array has the same number of elements, and all corresponding element 22 is equal.

Fill (): Fills the value into the array. Sort (): Used to sort the array.

BinarySearch (): Looks for elements in a sorted array.

System.arraycopy (): Copy of Array.

2, 2>collection and Collectionscollections.max (Collection coll); Gets the largest element in the collection.

Collections.sort (list list); Sort elements in List

3. Design Patterns and iterators

Iterator mode (Iterator): Provides a way to order individual elements in an aggregation object without exposing the internal representation of the object. Its main purpose is 1. Different containers provide the same iterator interface; 2. Use the iterator interface when accessing container internal content using a container; 3. When you change the container you are using, you only need to change the type of declaration, and the original code written for the other container will still be fully applicable to the new container. Knowledge of the Java container class

Iterators in Java: Functions are relatively simple and can only be moved one way.

(1) Use Method Iterator () requires the container to return a Iterator. The first time you call Iterator's next () method, it returns the first element of a sequence. Note: The iterator () method is an Java.lang.Iterable interface that is inherited by collection.

(2) Use Next () to get the next element in the sequence.

(3) Use Hasnext () to check if there are elements in the sequence.

(4) use remove () to delete the newly returned element of the iterator.

Iterator is the simplest implementation of Java iterators, with more functionality for the listiterator of list design, which can traverse the list in two directions or insert and delete elements from a list. Knowledge of the Java container class

4, comparable interface in the Java.lang package, the comparable interface is suitable for a class with a natural order. Assuming that the collection of objects is the same type, this interface allows you to sort the collections into natural order. There are not many classes to implement the comparable interface:

Class sort

BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, short sorted by number size

Character sorting by numeric size of Unicode values

Collationkey sorting by locale-sensitive strings

Date sorted by age

File sort by Unicode value of the fully qualified character of the system-specific path name

Objectstreamfield Sort by the Unicode value of the characters in the name

String sorted by character Unicode value in string

If have not understood the friend can add me q:2878908695, everybody together study progress, I in 2007 still school graduation, currently serving a large state-owned enterprise Java driving Architect, is committed to help more novice learning programming, share video, hope to help like Java friends. If you need any help, you can contact me.

Knowledge of the 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.