Difference between array and arraylist.

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between yielding and sleeping in java programming?

578


What is the meaning of 3 dots in java?

675


What is public/private protected in java?

536


How does predicate work in java?

527


When do we use hashset over treeset?

522






What do you know about java?

513


What is substring 1 in java?

579


Explain garbage collection in java?

537


Why declare Main() method as a static in java ?

591


What is tochararray in java?

492


What is the do while loop syntax?

546


How concurrent hashmap works?

600


What is skeleton and stub?

585


What is the output of the below java program?

583


What are design patterns and please explain?

564