Discussion of Activity 5.1 - Exploring the API documentation

Although we have only provided a quick tour of the documentation, you should now know enough to be able to use it whenever you need information about any feature of the API.

The Java language is vast and no single person can possibly know it all, so the documentation is an indispensable tool that all programmers need to consult very frequently.

Answers to Questions

Questions Section 4

(a) java.lang.Object

(b) Thirteen, two of which are deprecated (see below).

(c) Compares this string to another string, and returns an int.

(e) There is one deprecated method, one of the three methods called getBytes. Deprecated features should not normally be used and the API indicates alternative approaches. Typically, they were part of a previous version of the language, but do not work properly or are inconsistent in some way, such as their name or argument pattern. They remain in the API specification for a number of later versions, so that users know their status.

(f) Recall that overloaded methods have the same name but different patterns of arguments. The String class has a large number of methods and many of them are overloaded. There are 14 groups of overloaded methods in this class: contentEquals, copyValueOf, format, getBytes, indexOf, lastIndexOf, regionMatches, replace, split, startsWith, substring, toLowerCase, toUpperCase, valueOf.

Question Section 5

The method get(int) in java.util.LinkedList throws an IndexOutOfBoundsException. You could also have found this out by looking at the documentation for class java.util.LinkedList itself.