October 2017
Beginner
318 pages
7h 26m
English
To see this in action, let's write a program that would actually be a little more difficult to write if we just used a standard array instead of an ArrayList. I'd like to write a program that will take an input string from the user. It will store this input string with every other input string the user has ever given it, and then print them all out each time the user inputs a new string.
This would be really difficult to do with an array because if the user ever inputs one more string than the array was designed to hold, our array would, in the best-case scenario, not accept the string; in the worst-case scenario, our program might crash. But, our ArrayList object will simply resize to fit the number of strings ...
Read now
Unlock full access