Friday, June 5, 2020

Differences between array and collection

What are the main differences between array and collection?

ANS) Array and Collection are somewhat similar with respect to storing the references of objects and manipulating the data . But they differ in many ways. The main differences between the array and Collection are explained below :

ArrayCollection
Arrays are always of fixed in size.Collection's size can be changed dynamically as per need.
User can not increase or decrease the length of the array according to their requirements at runtime.User can increase or decrease the length of the Collection's according to their requirement at runtime. Collection's size grow automatically as and when requires.
Arrays can only store homogeneous or similar type of objectsCollections supports both homogeneous and heterogeneous objects to store.
Arrays cannot provide the ready-made method support for user requirements such as sorting, searching of the objects.Where as Collections have ready-made method support for user requirements

No comments:

Post a Comment

Hello Buddy, if you have any doubts or need any clarification , feel free to comment. Thanks.