Architecture
Almost all collections in Java are derived from the java.util.Collection interface. Collection defines the basic parts of all collections. The interface states the add and remove methods for adding to and removing from a collection respectively. Also required is the toArray method, which converts the collection into a simple array of all the elements in the collection. Finally, the contains method checks if a specified element is in the collection. The Collection interface is a subinterface of java.util.Iterable, so any Collection may be the target of a for-each statement. (The Iterable interface provides the iterator method used by for-each statements.) All collections have an iterator that goes through all of the elements in the collection. Additionally, Collection is a generic. Any collection can be written to store any class. For example, Collection
There are three main types of collections:
- Lists: always ordered, may contain duplicates and can be handled the same way as usual arrays
- Sets: cannot contain duplicates and provide random access to their elements
- Maps: connect unique keys with values, provide random access to its keys and may host duplicate values
Read more about this topic: Java Collections Framework
Famous quotes containing the word architecture:
“It seems a fantastic paradox, but it is nevertheless a most important truth, that no architecture can be truly noble which is not imperfect.”
—John Ruskin (18191900)
“All architecture is great architecture after sunset; perhaps architecture is really a nocturnal art, like the art of fireworks.”
—Gilbert Keith Chesterton (18741936)
“Defaced ruins of architecture and statuary, like the wrinkles of decrepitude of a once beautiful woman, only make one regret that one did not see them when they were enchanting.”
—Horace Walpole (17171797)