201711671224 "Java Programming" Chapter 9 learning summary

Learning content summary

Collect the behavior of objects, such as adding an object add () method, remove to remove an object () method, are defined in the java. Util.Collection in.
Since you can collect objects, but also objects can obtain one by one, this is the java .lang.Iterable defined behavior, which defines the iterator () method returns an object java.util.Iterator operation.
In the memory array will be connected to linear space, according to the fastest time index random access, if there is such a demand for the operation, such as sorting, can use Ar2rayList, better speed performance can be obtained.
When in operation LinkedList List interface, using the link structure, will not advance the cost of memory, random memory object you want to specify the index, will be relatively inefficient, each element of the link will refer to the next element, which is conducive to adjust the index order. If the collected objects often have changes in the index, maybe consider linking to the operations List would be better.
Regardless List, set or Queue, there will be a iterator () method, this method before JDK1.4, the behavior is defined in the collection interface, List, Set, Queue inherited from the Collection, so it has iterator () of .
In the java specification, with order-related behavior, usually better than the object itself is Comparable, or is otherwise specified Comparator object tell you how to arrange.
After JDK7 new attempt to close the resource (Try-With-Resources) syntax, you want to try it is automatically closed resources have been written in parentheses after the try.

Other (perception, thinking, etc.)

no

Reference material

  • "Java Programming"

Guess you like

Origin blog.csdn.net/nemeziz/article/details/84542859