r suraaj wrote:...array is object which holds a group of primitive values or references
where as arraylist object stores a group of objects...
An ArrayList contains references. It does not contain the objects themselves.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Oct 26, 2008
yes., what i write initially is wrong., ArrayList doesn't hold objects but it too holds object references.,
but the difference is .,
if we want to find out an element in array we have to search for the using a loop (generally for loop), but in arraly list if we want to search we can simply use contains(Object obj) method , it returns a boolean value.,
r suraaj wrote:...if we want to find out an element in array we have to search for the using a loop (generally for loop)...
An array itself has limited methods available (those inherited/overriden from Object, per JLS - 10.7 Array Members). But note that java.util.Arrays also provides some functionality for use with arrays, including sorting and searching (as applicable).