File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array Vs ArrayList

 
r suraaj
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 632
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you are correct.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 449
IntelliJ IDE Java Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please provide me if any info of you know than this.,

I would add that ArrayList would provide more flexibility in code.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
r suraaj
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic