xhtml
 

The Library

The input to a program is in text form, but the program often needs to convert it into numeric form before doing calculations. To convert the other way, we used a convenient shorthand "" + n to convert a number n into text. However, to convert text into a number, there isn't a convenient shorthand, so we need to find a library function to do the job.

One of the strengths of Java is that it has an extensive library of off-the-shelf software. Also, unlike some other languages, the library is part of the Java standard, which makes sure that the entire library is available, in an identical form, on every platform. The library is officially called the "Java 2 Platform API Specification", it comes in different versions to match the compiler, and we are using version 5.0 in this tutorial. API stands for Application Programming Interface, and refers to the interface (calling conventions) which a programmer uses to access off-the-shelf facilities.

The library is so extensive that nobody can learn it all. Instead, you have to have the library documentation available in a browser while you are programming. The library has thousands of methods. A method is a function or procedure which carries out some task and/or returns a result. The methods are grouped in classes. A class is a group of related methods, which you can think of as being in one file. (Actually, a class is a lot more than that, as we will see later). The classes are themselves organised into packages. A package is a group of classes, rather like a folder or directory.

At the moment, we are only interested in methods that are marked as static. These are typically functions, i.e. methods which don't do anything except return a result. In fact, these static methods are used less frequently than "normal" methods, but they are available at any time, without having to worry about objects, which we find out more about later.


Back