Java Collections Tutorial 01| Introduction to Collections | Java9s.com

Описание к видео Java Collections Tutorial 01| Introduction to Collections | Java9s.com

http://java9s.com/core-java/collectio...
A collection is a data structure which holds elements as a group.
So, to be able to group the elements, a data structure should provide facility to add and remove elements.
Sometimes, we would like to sort the elements in a particular order.
Collections not only hold the elements but also provide extra functionality of Sorting, finding elements inside them, Converting etc.,
Java collections framework provides interfaces, Implementations and more algorithms which mostly cater to the project requirements.
First let us take a look at the Interfaces those Java collections framework defines.

At the top of the Collections hierarchy there is this collection interface,

This interface declares some fundamental methods like add, remove, clear etc.,



There are more refined collection interfaces which are divided based on the ordering and sorting criteria they follow and all of them extend Collection interface.

*The next level of interfaces are Set, List and Queue. The bifurcation of the collections is based on how they maintain the ordering of the elements.

We will discuss in detail about each of these types going further.

If we go further one step down the hierarchy, You can see that the most important concrete implementation of collections are present at this level.
We have the Set related collections which hold only unique elements.
As part of this category, We can see HashSet, LinkedHashSet are the concrete implementations of the Set interface.
There are SortedSet, NavigableSet interfaces and TreeSet which is a concrete implementation of Both.

Then coming to List, We have ArrayList which is one of the most frequently used collections.
*We have Vector and LinkedList. You can see that LinkedList also implements Queue Interface. We will discuss more on LinkedList in coming sessions.

Then Queue has LinkedList and PriorityQueue as concrete implementations.
*There is also an interface called DQUEUE – A double ended queue which allows to add elements from both the ends.
*LinkedList implements both Queue and Dqueue interfaces.

Apart from the regular interfaces, we have Map which actually does not implement the collection interface like Set, List and Queue does.
The reason is that this is a different kind of data structure which hold that elements as a key value pair. So, to add elements for this kind of collection, we need to have methods which accept the key value pair and normal methods like add and remove that are present in Collection interface are not applicable or useful for this Data structure. That is one of the reasons why Map has its own hierarchy.
But as it is also a kind of collection, we will discuss this as part of the this series.
*Then Map has HashMap, HashTable as its concrete Implementations.
*There is also a SortedMap and NavigableMap interfaces which are implemented by TreeMap.
*We also have a LinkedHashMap which extends the HashMap.

Finally outside the data structures, there are some utility classes you should know which help in working with collections.
They are Collections class and Arrays class.
Remember to differentiate between the Collection interface and Collections class. When I say Collections… It is a utility class. And when I say Collection, I am talking about the interface.
Collections is a utility class which provides some methods to work with two collections.
It offers some functionality like transferring, comparing, converting kind of operations between two collections.
Arrays is a utility class which provides algorithms to do a binary search, copying a part of an array, fills an array with specified value etc.,

Other tutorial you might be interested:

Complete Java Beginners Tutorials:
   • Complete Java Tutorials |  java progr...  

Multithreading in Java tutorial:
   • Multithreading in Java Tutorials by J...  

Spring 3 MVC Framework tutorials:
   • Spring 3 MVC Framework Tutorials  

Spring Framework Tutorials:
   • Spring Framework Tutorials | Java9s  

Design Patterns in Java:
   • Design Patterns Tutorials in Java | G...  

Complete Generics Tutorials playlist
   • Generics in Java Tutorials | Java9s T...  

Комментарии

Информация по комментариям в разработке