Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Major difference between Array and ArrayList?

 
Kaustubh G Sharma
Ranch Hand
Posts: 1283
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the major differences between array and arraylist or rest of the collections...


kaustubh
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A good place to start is here.
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick difference:
A classic array: Easy to use, but can't grow dynamically.
An Array Class: An class with static utility method
An ArrayList class: An dynamic array list.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't forget that arrays can store primitives whereas ArrayLists cannot - the closest they get to storing primitives is storing wrapper objects (Integer etc) in combination with auto-boxing.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a side note : ArrayList is nothing but an array data structure
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not true. It uses an array for storage, true, but it adds so much more behaviour that you cannot call it an array anymore. It's a List, period.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic