Difference between array and arraylist.
Answers were Sorted based on User's Feedback
Answer / mohit
1-array is used for value type. but array list is used for reference type.
2-array is used for fixed size but aaray list is dyanamically increase at run time.
3-you can't resize an array but you can do resize the array list.
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / raja
The Methods Of ArrayList class are
1)Add
2)Remove
3)Clear
5)TrimToSize
6)Sort
7)Reverse
| Is This Answer Correct ? | 5 Yes | 2 No |
Answer / chinnu
Array:arrays is not for our requirement once we create a size next we cant change the size.in advance we cant estimate the size.its taking only homogeneous elements.
Array list:array list is same as collections and vectors.array list is or requirement we can change the size in advance also and estimate the size.its taking both homogeneous and heterogeneous elements .
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / prem
Array:
It is mainly used to store and retrive similar datatype
elements.
It is a limited storage.
So it's size not growable and shrinkable.
It will create array out of bound exception while we adding
more elements in an array after exceeding array size..
While we remove elements from array,the array size will be
same.size will not get reduce.
ArrayList:
It is a class.
It is a collection.
It is used to store different datatype objects.
It is growable and shirnkable.
So whenever we add elements in an ArrayList the size of
ArrayList will grow..While we remove element from an
ArrayList the size of ArrayList will get reduce..
So memory will get save..
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / vk
Array is a collection of similar data types,ArrayList is not you can store any type of data types in AL.ArrayList will autometically increase 50% of the size which we allocated previously, but Array wasn't.
ArrayList al= new ArrayList();
al.add("a");
al.add(10);
both can be accepted in ArrayList.
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / abhay shukla
1) Array is the one which can save similar data type
elements and the size is limited.
2) Array list is a collection which is capable of saving
different data typed objects, and is grow able.
3) Array is the collection of values of the same data type.
Array list is a class
| Is This Answer Correct ? | 4 Yes | 1 No |
Answer / bhavani
ARRAY:collection of same data items.
2.array is always of fixed size.
3.initializing an array is too long,then it results in wastage
of memory in heap.
ARRAYLIST : Collection of different data objects.
2.Dynamic in nature.
3.automatic resizing of the list.
4.methods used is:add,remove,insert,clear,sort,reverse....
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / nikhil agrawal
array contain the similar datatype element and their size is fixedd where as arraylist contain object and their size is not fixed as aaray and it can grow dynamically. and we can applied so many method on arraylist like add,remove,clear,size etc
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / priya
Simply,
Array is static ie, Size Does not grow, its fixed
ArrayList is dynamic, By adding values, it grows
| Is This Answer Correct ? | 5 Yes | 3 No |
What is a java developer salary?
When is the arraystoreexception thrown?
Why does java not support pointers?
Why char array is favored over string for the storage of passwords?
my method "abc" return array of interface "xyz" and "pqr" is abstract class implements abc and class "jkl" extends pqr My problem 1) when i call abc it retrun array xyz how can i do this hint xyz refer_xyz = new jkl(); but i can't create array. 2)I want to access method of jkl using reference of xyz??
How can we create a thread in java?
Why do we declare a class static?
What is the use of an interface?
How to handle a web browser resize operation?
What is the basic concept of java?
What is the difference between the final method and abstract method?
What are the restriction imposed on a static method or a static block of code?