Tino APCS

Understanding APIs

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, only telling us what methods we can access, how to interact with those methods, and what those methods will return to us.

You can always access the Java APIs at Oracle's Java website. Click on the version of Java you wish to retrieve the API for (likely 1.8 or the most recent one). You can download the APIs to your computer for offline access or access the online documentation. 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 a few classes, for example, only the DrawingTool class from the gpdraw package, you can add the class(es) individually with the code import gpdraw.DrawingTool;.

Last modified: December 09, 2023

Dark Mode

Outline