API stands for Application Programming Interface and is one of the most useful tools you will have while working with Java. APIs show exactly how to use pre-made classes. The DrawingTool Class Specifications handout in Lesson A1 is an example of a simplified API. It lists the classes and constructors so that we know which methods are available. APIs do not tell us how the programmer dealt with a problem or what kind of formulas they used internally, but just tells us what methods we can access, how to interact with those methods, and what those methods will return back to us.
You can always access the Java APIs at java.sun.com. Click on API Specifications on the main page and then choose the version of Java you wish to retrieve the API for. You can also download the APIs to your computer for offline access. Many Java programming environments can be set up to access the APIs from within your code.
-
The Java APIs are organized both by package and by class. Packages are groups of related classes that are “packaged” together. When you use the code import gpdraw.*;
you are adding the entire gpdraw package to your code. If you only need one or two classes from a package, you can add the classes individually with the code import gpdraw.DrawingTool;
.