Home >Java >javaTutorial >Detailed explanation of container instances of objects

Detailed explanation of container instances of objects

零下一度
零下一度Original
2017-06-25 11:05:241283browse

1. Iterator (iterator) and Enumeration (enumeration class) are both used to traverse collections, and they are both interfaces. The difference is that Enumeration can only read the data of the collection, while Iterator can delete data, and Iterator can replace Enumeration.

2. The types of sets include Vector, BitSet (a Vector composed of "binary bits"), Stack ("last in first out" (LIFO) collection), Hashtable ("key-value" pair).

3.Collection is the parent interface of Set and List. A List (list) must contain elements in a specific order, while a Set (set) cannot contain any repeated elements. Map, a series of "key-value" pairs. There are no duplicate key objects in the collection, and the value objects can be repeated.

4.Collection’s iterator() method can return an Iterator object for traversal.

5. If operations such as stacks and queues are involved, you should consider using List. If you need to quickly insert and delete elements, you should use LinkedList. If you need fast random access to elements, you should use ArrayLit.

The above is the detailed content of Detailed explanation of container instances of objects. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn