Build a Shopping List Application with ArrayList in Java
ArrayList What’s an ArrayList? Oracle documentation defines an ArrayList as a resizable array that implements List interface. ArrayList comes with a ton of methods that allow manipulation of the array. Some of the methods applicable in ArrayLize include, size, add, get, set, isEmpty and more. I will show how some of the methods work with using code. When defining an ArrayList, it is important to specify the type because ArrayList holds objects. Above,we have specified the type as String. As such, the ArrayList defined will only be able to hold elements of type String. Adding Items to ArrayList ArrayList provides add method that can be used to add items to ArrayList. The method can be called using ArrayList variable defined earlier. In our case, we have created a method and passed an item that will be added to ArrayList using add method. See the following screenshot: : Print items in an ArrayList I mentioned earlier that ArrayList provides several methods to manipulate d...