October 2017
Beginner
318 pages
7h 26m
English
We need to begin by importing java.util, because java.util is where the Scanner class, which we'll need to get user input, and the ArrayList class itself, live. Once we've declared a Scanner, which we'll utilize a bit more later, it's time for us to declare our ArrayList:
package echo;
import java.util.*;
public class Echo {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
ArrayList memory = new ArrayList();
}
}
Simply declaring ArrayList looks a lot like declaring any other object. We say what type of object we'd like to create. We give it a name. We use the new keyword because Java is going to have to set aside some memory to create this object since it's not a primitive. Then, we ...
Read now
Unlock full access