File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Array Vs ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Array Vs ArrayList" Watch "Array Vs ArrayList" New topic
Author

Array Vs ArrayList

r suraaj
Greenhorn

Joined: Oct 26, 2008
Posts: 16
Both Array , ArrayList are objects pointing to a group .

1)array is object which holds a group of primitive values or references
where as arraylist object stores a group of objects

2)we can't change the size of array dynamically , where as we can change the size of array list dynamically


were above 2 points are correct?

please provide me if any info of you know than this.,

thanks in advance.,
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Yes you are correct.

Life is easy because we write the source code.....
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

r suraaj wrote:
1)array is object which holds a group of primitive values or references
where as arraylist object stores a group of objects


So, we cant store the reference of the Object in ArrayList ?
Muhammad Khojaye
Ranch Hand

Joined: Apr 12, 2009
Posts: 449

please provide me if any info of you know than this.,

I would add that ArrayList would provide more flexibility in code.


http://muhammadkhojaye.blogspot.com/
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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
r suraaj
Greenhorn

Joined: Oct 26, 2008
Posts: 16
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.,
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array Vs ArrayList
 
Similar Threads
getting a Null pointer exception at this point
Differences
append a value to an array ?
Comparing ArrayList to a regular array
ArrayList Vector Collections Array