This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Difference between array and arraylist Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between array and arraylist" Watch "Difference between array and arraylist" New topic
Author

Difference between array and arraylist

Kandi Srinath
Greenhorn

Joined: May 22, 2010
Posts: 1
Can anyone suggest regarding this topic.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

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!).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
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 ... ...


BEE MBA PMP SCJP-6
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Arrays are a built-in feature of the Java programming language and JVM; ArrayList is just a class like any other class.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Which uses an array for its internal storage.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between array and arraylist