Interviews2 answers
What is difference between an Array and ArrayList?
2 Answers
ARRAY:-Generally we will declare arrays with fixed length.Arrays are strongly typed collection of same datatype and these arrays are fixed length that cannot be changed during run time. If we want to access values from arrays we need to pass index values.
Ex. string[] arr=new string[2];
arr[0]="zero";
arr[1]="one";
ARRAYTLIST:-Array lists are not strongly type collection. It will store values of different datatypes or same datatype. Array list size will increase or decrease dynamically it can take any size of values from any data type. These Array lists will be accessible with “System.Collections” namespace.
Ex:- ArrayList objstr = new ArrayList();
objstr.Add("welcome"); // Add string values
objstr.Add(10); // Add integer values
objstr.Add(10.05);// Add float values
PAUL KPosted Aug 15, 2014, 1:41 AM EDT
Array:
-Size is Fixed, can;t change @ runtime
-It's Collectio Of Same data-types
ArrayList:
-Size can't be Altered @ runtime as well as design time
-It's collection of different datatypes
Pavan RamamurthyPosted Aug 29, 2013, 2:26 AM EDT
