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 |
why interaction with server using javascript is difficult
how to get the max salary and name of employee from arraylist without using the Comperator or even Comparable interface?
Why is inheritance used in java?
Does it matter in what order catch statements for filenotfoundexception and ioexception are written?
Why do we need main method to execute a java program?
Name the components that are termed to be Heavy-weight component but available in Light-weight components?
what is mean by method signature?
How to sort a vector elements that contains the user define class object? (Note: If Suppose consider, A Student class contain two data members. They are String studentName and int rollNo. I am creating Four objects for this class, each object contains students details like name and roll no. Now i am storing that objects in vector and if i retiving the elements from the vector means then it should be display in sorting order)
3 Answers ProdEx Technologies,
Hi Anyone know the model / questions of the Federal bank sample questions for the post of Specialist Officers - Programmers. Please post if anyone have..
1) There are 10 different threads in runnable state. Each having priority 1 to 10. How does the CPU schedules or executes these threads?
How destructors are defined in java?
Explain, java is compatible with all servers but not all browsers?