Introduction to Collections framework in Java
The collections framework in Java refers to a commonality in implementation of the container classes (also referred to collection classes) such as Vector, Arrays, ArrayLists, LinkedList, Hashtable etc. which means that these can be manipulated independent of their representation using interoperability of unrelated APIs or use of common APIs.The main advantage of this unified architecture is that by way of implementing one of the basic interfaces say Collection, Set, List or Map the user defined class conforms to a common API which can easily be reused and also understood properly.
The collections framework in Java is feasible because of design of the collection interfaces where the basic interface is collection itself. For instance, Set, List and SortedSets are extended interfaces of the collection interface. Other important container interfaces Map and SortedMap do not extend the collection interface but can be manipulated like collections.
The java classes that implement the collection interfaces have names in combination of type of implementation prefixed to the type of interface, for example,
- HashSet, TreeSet, LinkedHashset typical general purpose classes using Set interface.
- ArrayList and LinkedList classes using List interface.
- HashMap,TreeMap and LinkedHashMap using Map interface
All java developers know about the Collections Framework!
But, they are all know more and more things from Collection Frameworks.
Most of us know the concept of Collections like (What is Collection? and what is ArrayList?) but the implementations is very difficult when u are going to use in your applications.
Here I make few questions about this topic.
Before going to know about Collection Framework, we must know the What is Framework?
Framework make easier to work with complex technologies.
It is a architecture that manages the collection of Objects and implement the set of specific design elements.
I hope you are all understand about the Framework.
Now we can move to What is Collections Framework?
Collection Framework is a architecture that contains set of Classes and Interfaces for storing and manipulating the group of Objects.
Advantages of Collection Framework
- Reduces programming effort by providing useful data structures and algorithms so you don't have to write them yourself.
- Increases performance by using data structures and algorithms.
- Provides interoperability between unrelated APIs.
- Reusability, standard interface for collections and algorithms to manipulate them.
Collections Framework for manipulating data collections.
When you are going to use the collections, you want to remember the following hierarchical relationship of the four basic interfaces of the framework,
- Collection ---> It is the root of the Collection hierarchy.
- Set ---> it is not allowed the duplicate elements.
- List ---> it is an Ordered Collection. It can contain duplicate elements.
- Map ---> It is store the Object as a Key, value pairs. It cannot contain duplicate keys; each key can map to at most one value.
- Note-
For reference:-
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html
No comments:
Post a Comment