Reading the Documentation

Reading the Documentation

One great thing about Java is that it has excellent documentation. For example, open the documentation for ArrayList

At the top, we see the following:

This tells us that ArrayList<E> extends AbstractList<E>, which extends AbstractCollection<E>, which extends Object. (Every class in java extends java.lang.Object, unless it explicitly extends some other class.) It also tells us which interfaces ArrayList implements.

Underneath this, there’s a description of the ArrayList class, followed by a list of its constructors, and then a list of its methods. Clicking on any method will take you to a longer description. For example, if you click on add(int index, E element), you’ll see this:

This tells us not only what add does, but what its parameters are and any exceptions it throws. It also tells us how this relates to any interfaces ArrayList implements or classes it extends.

Open the provided file ReadTheDocs.java

Read through the list of methods for ArrayList. Use your newfound knowledge to change the code in ReadTheDocs so that instead of printing the value at every index of the ArrayList, it only prints out the value of index 80 through the end of the list. You should be able to do this by only modifying one line of code, and not using any if statements.