• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Array Vs ArrayList

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.,
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes you are correct.
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Ranch Hand
Posts: 449
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
reply
    Bookmark Topic Watch Topic
  • New Topic