The Wayback Machine - http://web.archive.org/web/20210504172320/https://www.geeksforgeeks.org/array-vs-arraylist-in-java/amp/

Array vs ArrayList in Java

In Java, following are two different ways to create an array.

  1. Array: Simple fixed sized arrays that we create in Java, like below
          int arr[] = new int[10]   
  2. ArrayList : Dynamic sized arrays in Java that implement List interface.
          ArrayList<Type> arrL = new ArrayList<Type>();
          Here Type is the type of elements in ArrayList to
          be created
        

Differences between Array and ArrayList

As a side note, ArrayList in Java can be seen as similar to vector in C++.

 

This article is contributed by Pranjal Mathur. If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.




Article Tags :
Practice Tags :