The biggest difference is that you can add to and remove from a list, whereas arrays have a fixed size. Answer from sepp2k on reddit.com
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 8 )
April 21, 2026 - Java™ Platform Standard Ed. 8 ... public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable
🌐
W3Schools
w3schools.com › java › java_arraylist.asp
Java ArrayList
It is part of the java.util package and implements the List interface. The difference between a built-in array and an ArrayList in Java, is that the size of an array cannot be modified (if you want to add or remove elements to/from an array, you have to create a new one).
🌐
GeeksforGeeks
geeksforgeeks.org › java › arraylist-in-java
ArrayList in Java - GeeksforGeeks
ArrayList in Java is a resizable array provided in the java.util package.
Published   May 12, 2026
🌐
CodeHS
codehs.com › tutorial › 13901
Tutorial: ArrayLists in Java | CodeHS
Learn how to create and use ArrayLists in your programs!
🌐
Lawrence
www2.lawrence.edu › fast › GREGGJ › CMSC150 › 062ArrayLists › ArrayLists.html
Working with ArrayLists
The ArrayList class is a Java class that you can use to store lists of objects.
🌐
Reddit
reddit.com › r/javahelp › list vs array vs arraylist
r/javahelp on Reddit: List vs Array vs ArrayList
September 12, 2023 -

Coming from Python, this whole Java thing is incredibly confusing. The thing is, they don't seem to mix and uses different methods such as .size() vs .length(). All of them also seem to be doing the same thing: having a group of something.

I really need a comparison of the three, and how to declare, manipulate, and access, etc them.

Top answer
1 of 5
16
These are three different things: Array - a very basic data structure. It has a fixed, predetermined size that must be known at the time of creating (instantiating) the array. Think of it as a sorting box with several slots. Here, you have .length - without parentheses as it is a property, not a method List - an interface (not a class) that defines certain behavior. It cannot be instantiated on its own. ArrayList - a concrete class that implements the List interface. When you see a declaration like List data = new ArrayList<>(); there are several things going on: Listprogramming against the interface - here, the interface List is used as data type - this is good practice as it allows you to at any time change the internal representation of the List - e.g. from ArrayList to LinkedList if you figure out that the other better suits your needs. this is a data type identifier. It limits the type of elements that can be stored in the list. Here, only String objects are allowed. If you were to omit this, the list would store Object (the ancestor of all Java classes) and descendant instances (i.e. Object and any subclass of it). data - just the variable name new - the keyword to create a new Object Instance ArrayList<>() - the constructor call. Here, the constructor without parameters of the ArrayList class is called. The diamond operator <> is used to infer (take) the data type for the ArrayList from the variable type (here String). So, the whole is: we create a new variable of type List that can only accept String elements and ist internally represented as ArrayList.
2 of 5
4
Array An array is a data structure built into the Java language which can hold a number of elements, all of the same type. It cannot be resized once it has been created, and you cannot add elements to it without specifying an index. // creates an array of 10 ints int[] arr = new int[10]; // sets the value of the 0th element to 5 arr[0] = 5; // prints the value of the 0th element, which is 5 System.out.println(arr[0]); // Sets e to the value of the 0th element of arr, which is 5 int e = arr[0]; // Sets the value of the 1st element to 6 arr[1] = 6; // prints the length of arr System.out.println(arr.length); // even though arr[9] has not been set, // all elements initialize to 0 when first created System.out.println(arr[9]); /* Illegal operations! */ // an exception is thrown since arr can only hold 10 elements System.out.println(arr[11]); // there is no shorthand syntax to get the last element of an array System.out.println(arr[-1]); // length is a variable, not a method System.out.println(arr.length()); // arr can only hold ints arr[2] = "Hello"; List A List is an class that is part of the Java Standard Library which allows for dynamic insertion and deletion of elements. You can't just create a List though, you have to use one of its subclasses, which includes ArrayList, and you have to use generics as well. Think of an ArrayList as a dynamic version of an array, and is the closest thing to Python's list datatype. // Make sure to import these at the top of your class! import java.util.List; import java.util.ArrayList; // creates an ArrayList of ints List myList = new ArrayList<>(); // adds 5 to myList myList.add(5); // prints the 0th element of myList, which is 5 System.out.println(myList.get(0)); myList.add(6); // removes the last element of myList, which is 6 int removed = myList.remove(); // prints the size of the list, which is 1 System.out.println(myList.size()); /* Illegal operations! */ // myList only has 1 element System.out.println(list.get(5)); myList.remove(); // removes 5 // throws an exception since the list is empty myList.remove(); // throws an exception since myList can only take ints myList.add("Hello"); // you can only use bracket notation on arrays System.out.println(myList[0]); // size is a method, not a variable System.out.println(myList.size); Other Info There are lots of other List subclasses you can use depending on the kind of operations you want to do on it, such as Queues, LinkedLists, and PriorityQueues. The reason why we use Integer instead of int when working with Lists is a limitation of the Java language. Generic types can only be object types, but primitive types, such as int, double, boolean, etc., are not object types, and thus we have to use autoboxing to work with primitives in this manner.
🌐
Reddit
reddit.com › r/learnprogramming › java: is arraylist better than arrays?
r/learnprogramming on Reddit: Java: Is Arraylist better than Arrays?
June 23, 2024 -

I've been programming in Java for 10 months now (as a subject in school) and i was always curious whats the biggest difference between Areays and Arraylist. I know that if i had an Arraylist named 'list' and i wrote System.out.print(list) it will print all the things that the list contains. Something that Arrays can't do that easily. But whats the actually biggest difference?

Find elsewhere
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › docs › api › java.base › java › util › ArrayList.html
ArrayList (Java SE 21 & JDK 21)
January 20, 2026 - Each ArrayList instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added to an ArrayList, its capacity grows automatically.
🌐
Medium
rameshfadatare.medium.com › java-arraylist-c9de214b233d
Java ArrayList. Welcome to the Java Collections… | by Ramesh Fadatare | Medium
September 18, 2024 - ArrayList in Java is a resizable array implementation of the List interface. Unlike arrays, ArrayList can grow and shrink dynamically, which makes it a flexible and convenient data structure for managing collections of objects.
🌐
Reddit
reddit.com › r/javahelp › can someone please explain the difference between list and arraylist like i'm five?
r/javahelp on Reddit: Can someone please explain the difference between List and ArrayList like I'm five?
October 2, 2021 -

What exactly is the difference between

List<String> inputs = new ArrayList<>()

and

ArrayList<String> inputs = new ArrayList<>()

I've read some stuff about it but I'm a bit confused and I don't feel like I understood completely. Can someone explain the difference with some examples? Thank you!

🌐
Codecademy
codecademy.com › learn › learn-java › modules › learn-java-arrays-and-arraylists › cheatsheet
Learn Java: Arrays and ArrayLists Cheatsheet | Codecademy
In Java, an array is used to store a list of elements of the same datatype. Arrays are fixed in size and their elements are ordered. ... Using the {} notation, by adding each element all at once.
🌐
Oracle
docs.oracle.com › javase › 7 › docs › api › java › util › ArrayList.html
ArrayList (Java Platform SE 7 )
Java™ Platform Standard Ed. 7 ... public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable
Top answer
1 of 1
2
public ArrayList<Integer> onlyPrimes(int[] numbers) {
    ArrayList<Integer> primes = new ArrayList<Integer>();
    …
}

my mind can’t wrap around what is happening with these 2 lines

I can understand your confusion. There is a lot going on in those two lines.

Line # 1

The first line defines the signature of a method. The name of the method will be onlyPrimes. This method will return a reference to an object, an instance of the class ArrayList (or return a null). The ArrayList object will contain zero, one, or more elements, each element being a reference to an object of the class Integer. When a programmer calls this onlyPrimes method, she will pass an array ([]) of primitive int values (or pass a null). Within the body of our onlyPrimes method, this passed array will be known as numbers.

By this declaration, any calling programmer knows that 👉🏾 if they hand over an array of primitive int values, they get back a collection of Integer objects.

You may be getting especially confused by the fact that Java has two parallel type systems: primitives and objects:

  • Java was intended to be a thoroughly object-oriented language.
  • The primitives type system was also put into Java to (a) make learning easier to the majority of programmers then who were used to C-like languages, and (b) facilitate porting C code into Java.

The two type systems (objects & primitives) are bridged by auto-boxing with wrapper classes such as Integer for int.

Line # 2

The next line is the first line in the body of our method named onlyPrimes. Notice how I corrected your indenting to make clear this relationship between (a) the declaration of a method, and (b) the body of that method. The { curly-brace marks the opening of the body of the declared method.

This first line of the method body declares an object reference variable named primes. That variable shall hold a reference to an instance of the class ArrayList. This instance is a collection of objects of the class Integer. The EQUALS sign assigns an object reference to our variable primes.

The code after the EQUALS sign instantiates a new collection, an object of the class ArrayList. That collection is empty, holding no elements, but is capable of holding references to objects of the class Integer. The instantiation returns a reference to the new collection object. That reference is assigned as the content of the object reference variable we declared with name of primes.

Tutorials

I suggest you study a simpler tutorial that goes over the various parts of this code.

  • A good place to start is The Java Tutorials, by Oracle Corp, provided free of cost.
  • Another excellent tutorial is the book Head First Java, 3rd Edition by Kathy Sierra, Bert Bates, Trisha Gee.

Improving that code

I would make some changes to that code.

I would mark the method parameter as final to ensure that in the method body no other reference is assigned to numbers.

The passed argument should be validated, to be sure the calling programmer did not pass a null. A handy way to make this check is a call to Objects.requireNonNull.

We needn’t repeat the Integer as the type of the list in the second line. The compiler in modern Java can deduce that type. So just use <>.

Generally it is best to use the highest possible superclass or superinterface that offers the needed functionality. The superinterface of ArrayList is List. In Java 21 and later, an even higher superinterface is SequencedCollection (see JEP 431).

I am one of those folks who thinks it generally best to return an unmodifiable collection. So after populating the ArrayList, I would generate a new unmodifiable List by calling List.copyOf.

I would let the text of the code breathe, adding some SPACE characters. The crammed-together style is a historical artifact dating back to the 80-column limits of punched cards and terminals.

public SequencedCollection < Integer > onlyPrimes( final int[] numbers ) {
    Objects.requireNonNull( numbers ) ;
    SequencedCollection < Integer > primes = new ArrayList<>();
    …
    return List.copyOf( primes ) ;
}
🌐
Medium
harsh05.medium.com › mastering-collections-in-java-why-and-how-to-use-arraylist-98bb8cb202ca
Mastering Collections in Java: Why and How to Use ArrayList | by @Harsh | Medium
October 13, 2024 - Collections provide a way to manage and manipulate groups of data in Java, solving many of the challenges posed by traditional arrays. In this blog, we’ll explore why collections are necessary, the limitations of arrays, and how ArrayList, one of the key implementations of the Java Collection Framework, overcomes these issues.
🌐
Career Karma
careerkarma.com › blog › java › arraylist java: a beginner’s guide
ArrayList Java: A Beginner’s Guide | Career Karma
December 1, 2023 - An ArrayList is a special type of list that allows you to create resizable arrays. The ArrayList class implements the List interface, which is used to store ordered data. When you’re working with an array in Java, you’ve got to declare the ...
🌐
Medium
medium.com › @AlexanderObregon › java-arrays-and-arraylists-a-comparative-look-bcbc97b32a1e
Java Arrays and ArrayLists: A Comparative Look
November 18, 2023 - Choosing between arrays and ArrayLists in Java boils down to the specific requirements of the application. If the collection’s size is fixed and performance is a key concern, arrays are the better choice. For scenarios requiring flexibility in size and high-level operations, ArrayLists are more appropriate.
🌐
Android Developers
developer.android.com › api reference › arraylist
ArrayList | API reference | Android Developers
Skip to main content · English · Deutsch · Español – América Latina · Français · Indonesia · Polski · Português – Brasil · Tiếng Việt · 中文 – 简体
🌐
Medium
medium.com › @pratik.941 › mastering-arraylist-in-java-a-comprehensive-guide-0b6c78607a62
Mastering ArrayList in Java: A Comprehensive Guide | by Pratik T | Medium
June 2, 2024 - The `ArrayList` class in Java is part of the `java.util` package and is a resizable array implementation of the `List` interface. It provides dynamic arrays that can grow and shrink in size, making it a versatile and powerful tool for managing ...