Hello Readers, Once again welcome back to Java Jagran. Today i am going to talk about Collection framework in java. You people might be heard from others that collection framework is very important topic in java. Yes, it's a very important topic with respect to interview, with respect to exams and most important with respect to work. There is no java project in this world without using Collection framework.
Now, the question is why Collection framework is important? Take an real time project example. For example you are working on a EMS(Employee Management System). In that you have one page for search employees. So for that you have to carry group of employee objects from one layer of application to another layer(DAO layer to Service layer, Service layer to presentation layer). So we can't take multiple objects from one class to another class, one method to another method. For that we need some wrapper in which we can put all the employee objects and send from one place to another place. Same what collection doing. Collection framework doing the work of wrapper or you can say like a bag. We can put all the employee object inside Collection object and send from one layer of application to another layer of application.
Some people used to say that we can use array also for the same. But there is too many benefits of using collection over array. The main problems with arrays is:
We are getting so many pre-defined operations in the form of methods. For example we have to search an item in array, we have to write lot of code for that(We have to implement one of the searching algorithm). But with the collection it's too simple. All the collection classes provided one or other methods for searching an item from the collection. Same for the adding, removing, updating etc.
The next question is why collection is called framework? You people might be heard that Spring, Hibernate, Struts etc are frameworks. But how and why collection? For that first we have to understand the concept of framework. When we can call framework and when we call technology. Framework is almost ready thinks. I means to say that whatever logic is common for all the application that that is provided by a framework. And we have to write only business specific logic for building applications. Collections also providing the same. In the case of collections also same. Actually collection is the well implemented DS(Data Structures). In C language and some other languages we have to write the code by our self. But Java people provided a classes for all the DS and that is given a name as Collection. So we no need to write code for that, we can directly use those classes. That's why Collection is called framework. That's all for now. Hope you people will get benefited by this. For more information keep reading Java Jagran.
You can also get so many thinks related to java at bellow given YouTube and Facebook:
Now, the question is why Collection framework is important? Take an real time project example. For example you are working on a EMS(Employee Management System). In that you have one page for search employees. So for that you have to carry group of employee objects from one layer of application to another layer(DAO layer to Service layer, Service layer to presentation layer). So we can't take multiple objects from one class to another class, one method to another method. For that we need some wrapper in which we can put all the employee objects and send from one place to another place. Same what collection doing. Collection framework doing the work of wrapper or you can say like a bag. We can put all the employee object inside Collection object and send from one layer of application to another layer of application.
Some people used to say that we can use array also for the same. But there is too many benefits of using collection over array. The main problems with arrays is:
- Array is fix in size( We have to decide the size before creating array)
- It's very hard to do CURD(Create-Insert, Update, Retrieve, Delete-Remove) operations on array.
- We can't store heterogeneous object in array.
We are getting so many pre-defined operations in the form of methods. For example we have to search an item in array, we have to write lot of code for that(We have to implement one of the searching algorithm). But with the collection it's too simple. All the collection classes provided one or other methods for searching an item from the collection. Same for the adding, removing, updating etc.
The next question is why collection is called framework? You people might be heard that Spring, Hibernate, Struts etc are frameworks. But how and why collection? For that first we have to understand the concept of framework. When we can call framework and when we call technology. Framework is almost ready thinks. I means to say that whatever logic is common for all the application that that is provided by a framework. And we have to write only business specific logic for building applications. Collections also providing the same. In the case of collections also same. Actually collection is the well implemented DS(Data Structures). In C language and some other languages we have to write the code by our self. But Java people provided a classes for all the DS and that is given a name as Collection. So we no need to write code for that, we can directly use those classes. That's why Collection is called framework. That's all for now. Hope you people will get benefited by this. For more information keep reading Java Jagran.
You can also get so many thinks related to java at bellow given YouTube and Facebook:
No comments:
Post a Comment