- Introduction to JVM Languages
- Vincent van der Leun
- 143字
- 2021-07-02 21:46:29
ArrayList (java.util.ArrayList)
This is a fairly simple and convenient class to work with. As the name implies, it implements the List structure that can hold other objects.
While the JVM platform and most JVM languages have built-in array support, the ArrayList object is easier to work with. A couple of advantages of ArrayList over normal arrays are as follows:
- The ArrayList object will automatically grow when it is full and more space is needed. Arrays have to be managed manually.
- Arrays only offer one attribute (to get the size of the array), while the ArrayList class offers a lot of convenient methods.
Although the arrays on a JVM do not have built-in methods, Java offers the java.util.Arrays class with many methods to make working with arrays easier. Some JVM languages even add methods to arrays.
Let's look at some methods and example code.