Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between array and arraylist  RSS feed

 
Kandi Srinath
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone suggest regarding this topic.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays can hold primitives and have a fixed length. ArrayList is a class that implements List that can only store objects and can grow as more elements are added.

But you could have found this out if you had checked the Java Language Specification for arrays and the Javadoc pages for ArrayList (just click on the word!).
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
They are very different beasts. Array is a more foundational concept, very
powerful and very general purpose. List is a utility interface with methods
like clear(), add() and remove(). The class ArrayList is a "Resizable array
implementation of the List interface." It uses an array behind the scenes.

Jim ... ...
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15865
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arrays are a built-in feature of the Java programming language and JVM; ArrayList is just a class like any other class.
 
Rob Spoor
Sheriff
Posts: 20904
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which uses an array for its internal storage.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!