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
Which method must be implemented by all threads?
What does function identity () do?
What is ellipsis in java?
How do you initialize an arraylist in java?
What is the role of garbage collector in java?
Do I need java on my computer?
What is indexof in java?
What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?
Can constructor return value?
Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?
What is class and its types?
For class CFoo { }; what default methods will the compiler generate for you>?
How we can skip finally block of exception even if some exception occurs in the exception block in java?
What is strings in java?
What is the difference between static class and normal class?