March 17, 2010

Difference between array and arraylist ?

Array is a primitive data structure, which stores the values in indexed format.
ArrayList is a mre like a vector. (A re-sizeable array). It is a collection and stores any value as an object.
OR
array is the one which can save similar data typed elements.And the size is limited.
arraylist is a collection which is capable of saving  different data typed objects,And is growable.
OR
1)An array can be of any data type and contain one data type while array list can contain any data type in the form of the object.2)With array you can not dynamically increase or decrease the size of array dynamically. You must the define the size of the array. You can change the size of the array with redim statement but still you have to define type. While with array list you can make list of any sizes. When a element or object is added to array list it size is automatically increase the capacity of the array list.
3)once you delete the item in array it kept that one as empty like a[2]="" but in case of arraylist a[3]index occupies the position of a[2] and also if you try to insert a[2] value array will throw error if any items reside inside but in case of arraylist a[2] is inserted in same position but at the same time position of a[2] become a[3] if there is already an item exists

No comments:

Post a Comment

I'm certainly not an expert, but I'll try my hardest to explain what I do know and research what I don't know.

My Favorite Site's List

#update below script more than 500 posts