It is possible to store a group of onjects into an array
Let us take an example where we want to store 100 object
of employee class into an array.
Employee arr[]=new Employee[100];
For(int i=0; i<100;i++)
{
Arr[i]=new Employee(data);
}
So, here we can observe that how can we store group of object into an array and retrieve them easily. But we have some inconveniences by using this mechanism, they are as follows
Employee arr[]=new Employee[100];
For(int i=0; i<100;i++)
{
Arr[i]=new Employee(data);
}
So, here we can observe that how can we store group of object into an array and retrieve them easily. But we have some inconveniences by using this mechanism, they are as follows
We cannot store different objects into
the same array, because we knows that an array can store one data type of
elements.
Adding the objects at the end of an
array is easy, but inserting and deleting the elements in the middle of an
array is very difficult/complicated.
Retrieving elements from an array is
easy but after retrieving the elements,
if we want to process them, then there is no methods available to carry out
this.
Due to have of above problems, programmers want a better mechanism to store a group of objects. That mechanism is collection framework to handle group of objects of different type.
Due to have of above problems, programmers want a better mechanism to store a group of objects. That mechanism is collection framework to handle group of objects of different type.
No comments:
Post a Comment