Arrays are of fixed size.
Drawbacks:
When we add more number of values to an array than the original size of the array, arrays cannot resize themselves automatically.
ArrayList
Array List is similar to an array, as the number of values are added to the array List. We can add, insert and delete items into an Array List very easily.
And Array List stores any type of data inherited from System. Object. In a single Array list we can store any data type - integer, string and any type of object inherited from System. Object.
Briefly, an array contains one data type(int) whereas array list can contain many data types(int,float,char), the data in an array is accessed by indexes. Traversing the data in the amaryllis can be done by using for. Each loop or using enumerators or using indexers.
If you delete an item in an array, it keeps that position empty, whereas in an array list that position is occupied by the next element.
Drawbacks:
When we add more number of values to an array than the original size of the array, arrays cannot resize themselves automatically.
ArrayList
Array List is similar to an array, as the number of values are added to the array List. We can add, insert and delete items into an Array List very easily.
And Array List stores any type of data inherited from System. Object. In a single Array list we can store any data type - integer, string and any type of object inherited from System. Object.
Briefly, an array contains one data type(int) whereas array list can contain many data types(int,float,char), the data in an array is accessed by indexes. Traversing the data in the amaryllis can be done by using for. Each loop or using enumerators or using indexers.
If you delete an item in an array, it keeps that position empty, whereas in an array list that position is occupied by the next element.
No comments:
Post a Comment
Thank you for visiting my blog