answersLogoWhite

0


Best Answer

Terms from computer science:

You can imagine list like as string of pearls. They are connected with thread. If you got one you can go by thread to the other one next to it.

An array is like a meter. You know where you are so you can jump any amount of units around.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

16y ago

I am assuming that you are talking about Linked List and Arrays, Linked list are made up of nodes, which reference data and another node. Arrays on the other hand are just simply blocks in the memory to hold sequential data.

Thus Arrays require contiguous memory (the memory allocated must be together, and increasing this allocation may need a new location, since new data may overflow to pre-existing data), while Linked Lists do not.

Since Linked Lists are "linked" sequentially, there is no support for random access (all access must be traversals from the front to the desired value).

Arrays are more efficient for data structures that are rarely modify (thus getting around the contiguous memory requirement), and Linked List allow efficient modification (all adds and removes are constant efficiency, while arrays must shift elements).

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

A "collection" is a type of object that holds related data objects. Depending on the language you are using, collections might include hash tables, dictionaries, vectors, arrays, lists, sets, maps, stacks, queues, or any other type of object whose purpose is to contain sets of data that can be iterated or accessed in a variety of ways. An array is a specific type of collection that is of fixed size, and provides access to records through indices.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

in Arraylist - will face issues Like Boxing and unboxing But in List (Generics) No boxing and Unboxing so that generics are type safety example : private void button1_Click

(object sender, EventArgs e)

{

//Arraylist - Arraylist accept values as object

//So i can give any type of data in to that.

//Here in this eg: an arraylist object accepting

//values like String,int,decimal, char and a custom object

Employee emp = new Employee("2", "Litson");

ArrayList arr = new ArrayList();

arr.Add("Sabu");

arr.Add(234);

arr.Add(45.236);

arr.Add(emp);

arr.Add('s');

//This process is known as boxing

//To get inserted vales from arraylist we have to specify the index.

//So it will return that values as object.

//we have to cast that value from object to its original type.

String name = (String)arr[0];

int num = (int)arr[1];

decimal dec = (decimal)arr[2];

Employee em = (Employee)arr[3];

char c = (char)arr[4];

//This process that is converting from object to its original type is known as unboxing

//------------------------------------------------------------------------------------

//Generic List

//List<>

//Main advantage of Generic List is we can specify the type of data we are going to insert in to

//List. So that we can avoid boxing and unboxing

//Eg:

List<String> strLst = new List<string>();

strLst.Add("Sabu");//Here List accepting values as String only

strLst.Add("Litson");

strLst.Add("Sabu");

strLst.Add("Sabu");

List<int> intLst = new List<int>();

intLst.Add(12);//Here List accepting values as int only

intLst.Add(14);

intLst.Add(89);

intLst.Add(34);

List<decimal> decLst = new List<decimal>();

decLst.Add(2.5M);//Here List accepting values as deciaml only

decLst.Add(14.4587m);

decLst.Add(89.258m);

decLst.Add(34.159m);

List<Employee> empLst = new List<Employee>();

empLst.Add(new Employee("1", "Sabu"));//Here List accepting Employee Objects only

empLst.Add(new Employee("2", "Mahesh"));

empLst.Add(new Employee("3", "Sajith"));

empLst.Add(new Employee("4", "Binu"));

//To get values from Generic List

String nme = strLst[0]; //No need of casting

int nm = intLst[0];

Decimal decVal = decLst[0];

Employee empVal = empLst[0];

}

Thanks khiroj kumar sahu (khiroj.kumarsahu@photoninfotech.net)

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

An array list contains primitive types, while an ArrayList contains objects. However, this does not mean that an ArrayList cannot hold integers. In fact, through auto-boxing, int are automatically converted into Integers before put into ArrayList.

Another difference is that an array has a fixed number of items in it, while an ArrayList can grow or shrink.

An ArrayList has its own methods from import java.util.ArrayList. For example, to retrieve an object in a certain location, you would use get(i). However, for an array you would have to access array[i].

Another difference is how you initialize it:

ArrayList<String> theList = new ArrayList<String>();

compared to

String[] theList = new String[i];

There are many difference, but ultimately, it is up to you to decide which one is easier to work with.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

In VB.net, an Array has a defined count, whereas an ArrayList can be populated dynamically. You can perform advanced calculations on an Array, making it more powerful, but it is much easier to populate an ArrayList. For example:

For i as integer = 0 to 100

ReDim Preserve myArray(i)

myArray(i) = i

Next

For i as Integer = 0 to 100

myArrayList(i) = i

Next

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

An array list is a collection of one or more (usually more) elements arranged in memory in a consecutive fashion, accessed as one indexable entity. The upside is that overhead is small. The downside is that size is fixed, unless you implement some method of size extension, copying, deleting, etc.

A linked list is a collection of one or more (usually more) elements arranged in memory in a (usually) dis-contiguous fashion, using pointers contained in each element that point to the next element in the list. Each element is allocated one at a time (although some algorithms can allocate chunks, in order to optimize things). The upside is that the list is growable to the limit of available memory. The downside is that there is overhead, both in element size and in addition, deletion, and searching.

This answer is:
User Avatar

User Avatar

Anmol dhiman

Lvl 2
3y ago

Arraylist provide a lot of functionalities over array .Array have fixed size and can not increase dynamically if there is need during of execution . But in case of arraylist it can increase their size if needed .So we can say array is fixed in size and arraylist is dynamic or re sizable array .Second , arraylist provide a lot of predefined method for different functionalities so it make developer work easy because these method well efficient.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between arraylist and array
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What advantage does the Java ArrayList class have over the Arrays class?

The biggest advantage of an ArrayList is that it can expand in size to fit more data. So, if you don't know how many data values you are going to have, you can construct an ArrayList. Whenever you use the add() method, the object will be added to the ArrayList, regardless of the current size. An Array does not have this advantage. When you construct an Array of size n, the array will always be that size.


Diffbetween array and arraylist?

An array is a fixed-length chunk of memory. Once you've created an array, you can't change its length. This can be a problem. So we have ArrayList. This is a data structure backed by an array. You can add/remove/insert elements whenever and wherever you want and the code behind the scenes will take care of resizing the array for you.


How you can store a class variables in array list?

An (non generic) arrayList in java can save any type of object (in this case your class variable) in this straightforward way: MyClass myClassVar = new MyClass(); ArrayList myArrayList = new ArrayList(); myArrayList.add(myClassVar);


How can you create array of an object in java?

Array's can hold only primitive data types. if you want a collection of objects you must use an ArrayList or a Vector.


An array may have some elements that are numbers and other that are strings?

No, but an arraylist or almost any other list abstraction can


What is the difference between numeric array and associative array?

Numeric array has numbers(+integers) that represent the values Associative array has strings that represent the values


How do you sort the integer numbers of arraylist in java?

You can also use the Collections.sort() method to sort values in an array list. You can also use the Comparable Interface or Comparators for providing custom implementations of sorting algorithms for values inside an ArrayList.


What is the difference between array and string of array?

When we declare an array of characters it has to be terminated by the NULL , but termination by NULL in case of string is automatic.


JVM is platform independent dependent why 2 which one is faster in execution Array List or Array why?

If im sending the answer if correct means u can accept otherwise any comments reply me. My mail is is murugadoit@gmail.com i know the answer is JVM is platform dependent, but Java is platform independent. Array is faster execution then ArrayList. Array is similar to pointer. You can store the values in index based. So you can easily store the data and also rectify the datas. So Array is faster then ArrayList but both are working datastructure in internally.


Difference between vector and array list?

Vectors are thread safe but array lists are not. Hence array lists are faster than Vectors.


What is the difference between Land Grid Array and Pin Grid Array?

One has pin in front, one has land


What is Difference between programmable logic array and programmable array logic?

Using and gate - pla is programmable while pal is fixed