
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of arraylists in java, a class that creates a dynamic array of objects with the ability to add and remove elements. Arraylists are part of the java.util package and allow data elements to be inserted and deleted from any location. Some methods from the arraylist interface, including constructors, size, add and remove methods, and retrieval methods.
Typology: Study notes
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Java has a nice class that creates a flexible array of objects, using shifting to make and cover “holes” to allow adding and removing elements. When needed, more space is allocated for a growing number of elements. ArrayList is part of the java.util package. ArrayLists dynamically grow and shrink and allow data elements to be inserted and deleted from any location (index). An ArrayList stores Objects, which means that when you retrieve an element from an ArrayList you almost always need to cast it to its actual type.
How ArrayLists are actually implemented is not of concern to us. All we care about is their interface. The following list provides some, but definitely not all, methods from the ArrayList interface:
We will demonstrate the use ArrayLists in the Travelling Salesman Problem.