Java Collection Learning Summary

Source: Internet
Author: User

Review the collection provided by the standard Java (1.0 and 1.1) libraries (Bitset is not included here because it is more like a class with a special Mission):
(1) The array contains the digitized index of the object. It accommodates objects of a known type, so you do not have to sculpt the results when looking for an object. Arrays can be multidimensional and can hold basic data types. But once it has been created, the urine can't change. The
(2) vector (vectors) also contains the numeric index of an object--you can imagine arrays and vectors as random access collections. When we add more elements, the vector can automatically change its size. However, the vector can only hold the handle of the object, so it cannot contain the basic data type, and when an object handle is taken out of the collection, the result must be styled. A
(3) Hashtable (hash list) is a type of dictionary (dictionary) that is a way of associating an object, rather than a number, with another object. The hash table also supports random access to objects, and in fact its entire design is focused on the "high speed" of access. The
(4) stack is a "back to first Out" (LIFO) queue.

If you've ever been familiar with data structures, you might wonder why you didn't see a larger set. From a functional point of view, do you really need a larger set? For Hashtable, you can place anything in it and retrieve it at a very fast rate, and for enumeration (enumerations), you can iterate through a sequence and take a specific action on each of these elements. It's a tool that's powerful enough.
But Hashtable does not have a "sequential" concept. Vectors and arrays provide us with a linear order, but to insert an element into the middle of any one of them is usually a "heavy" price. In addition, queues, split queues, priority queues, and trees all involve "ordering" of elements-not just placing them in order to find or move them in a linear order later. These data structures are also very useful, which is why standard C + + contains them. For this reason, you should only consider a collection of standard Java libraries as a starting point for yourself. And if you have to use Java 1.0 or 1.1, you can use JGL when you need to go beyond them.
If you can use Java 1.2, you can use only a new set, which generally meets all our needs. Note that this book spends a great deal of space on Java 1.1, so a lot of the collections used in the book are those that can only be used in Java1.1: vectors and Hashtable. For the moment, this is a practice that cannot be achieved. However, this process also provides better backward compatibility with older Java code. To write new code with Java1.2, a new collection can often serve you better.

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.