A set is a data structure that contains at most one of any element.
A list is a data structure that contains any number of any element.
A map is a data structure that contains (key, value) pairs where a key is assigned to at most one value.
An iterator is a type of object that is used to traverse a data structure.
ArrayList<int>
? What should you do instead?
Because int is a primitive and not an Object. You should do ArrayList<Integer>.
public void print(ArrayList<String> list){ Iterator<String> it = list.iterator(); while(it.hasNext()){ System.out.println(it.next()); } }
public void print(ArrayList<String> list){ for(String s : list) System.out.println(s); }
type-checking support, more flexible code, code reuse.
ArrayList<String> as a type does not exist