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 |
How multi processing is achieved in JAVA?
Is it safe for adding 10,00,000 records/objects to HashMap?, i.e is it safe to add millions of objects to HashMap?
can u give one sinario when you use Abstract Class and When you use Interface.
What does singleton class mean?
What does @override mean?
What do you mean by hashing?
Can bool be null?
How do you escape json?
What is the concept of multithreading?
How many times finalize method will be invoked? Who invokes finalize() method in java?
How do generics work in java?
what are the differences between java and .net?..why u choose java?