We have come to a point that i think you are ready to explore what Java is all about. You will often hear me say “RTFM”, i.e Read The Fine (??) Manual! In Java this is more feasible than any other language. The documentation is well structured and well written. Nothing is left out. To be exact every bit of code is documented for us to see how to use it. The full documentation API is availiable here. You can also download a local copy for your reference here. But let’s see how you can get all the info from the documentation…
Take a quick look at the image below:
There are three parts on the browser now…
- This is the part that shows all the available packages on the JDK (Java Development Kit). This is where you start off. Choose the package you want (Here i chose the java.lang).
- This is where you should look after you choose a package. Here all the classes are listed on the package, group by interfaces, classes and exceptions. Click the class you want (here i chose the String class).
- This is the final part. This is where all the info about this class are displayed. As you can see there are info about the class hierarchy, all known subclasses. If it was an interface you would see all known implementers.
Now, the documentation starts with general information about the class. What it does, any tips etc. Then if you scroll down you should see three (at most) tables, the field list, the constructor list and the method list. Take a look at the image below:
Now. Let’s take a quick look.
- This is the modified of the field. As you can see this field is static. It could also be final.
- This is the type of the field. This is a PrintStream.
- This is the name of the field.
- Now we are into the methods (whatever goes here same goes for the constructors except for the return type). This is the modifier of the method. It is static, it could also be abstract.
- This is the return type. This method returns void (absolutely nothing).
- This is the name of the method. This one is called arraycopy.
- Finally, these are the parameters of the method. Below that, you can see a short description of the method.
For each one you get a short description. To get a closer look click on a field, constructor or method and you will be taken to the detailed view. There, for methods especially, you can see if it throws any exception, what is everything it returns etc. Take a peak.
You need to be very comfortable about the documentation because it is the most crucial knowledge on Java, to know where to find information about a class you need to use. On a next tutorial we will see how we can easily create our own javadocs on our code. Just a small hint. They are automatically generated! No need for HTML or anything. Just a small tool 😉