diff b/w array and array list and example

Posted by Venky.Net under C# on 4/6/2012 | Points: 10 | Views : 12249 | Status : [Member] | Replies : 5
what is difference between array and arraylist?and example?




Responses

Posted by: Yvamsi9 on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Array -> Collection of Homogeneous items.
ArrayList -> Collection of Heterogeneous items.
int [] a ={1,2,3,4,5,6};//It is an array which can acommodate only integers.
coming to arraylist it can hold data of any type->It is a collection(arraylist).
ArrayList al = new ArrayList();
al.add("Dotnet");
al.add(34);
al.add('w');

//It is an arraylist which can hold data of various types(string,char,int,double e.t.c.,);
This is the major difference between an array and arraylist .

Thanks,

Vamsi yadu .K

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi


Difference Between array And ArrayList


Array


Array is of fixed size
Array is the collection of values of the same data type
Array mainly used to save variables of same data type
>the variables in an array is called array elements
>Array is a reference type data type


ArrayList


-ArrayList is allowed to grow as needed
-Array list are collection of objects of same type or different type.
-Its a Collection of Objects with Sorting Feature.
-Array list is used to store and retrieve the variables of different data type.
-Array list is a class .



R D Patel

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

for more detail please refer this link

http://www.allinterview.com/showanswers/4105.html

http://www.dotnetspider.com/resources/37783-Difference-between-Array-ArrayList.aspx

R D Patel

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/6/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

here is nice Example

http://www.morkalork.com/mork/article/115/The_difference_between_array_and_arraylist.htm

R D Patel

Venky.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response