Java - API - Class Library


Classes, interfaces, constructors, members, and serialized forms are collectively known as API elements.

A class whose implementation uses an API is a client of the API. An exported API consists of the API elements that are accessible outside of the package that defines the API.

A class library (a set of packages and method) suitable for use in your own applications is known as the “Application Programming Interface”, or “API” for short.

In general, it is good API design practice not to make users pay for a feature they don't use.

An example would be a package of PDF processing methods that you want use to read PDF data (Tika for instance). A third party has written classes to implement an interface, which it makes public. You will invokes the public PDF methods using the signatures and return types defined in the interface.

While the PDF API is made public (to its user), the implementation of the API is unknown and may be revised at a later date as long as it continues to implement the original interface that the users have relied on.

APIs are then common in commercial software products. Typically, a company sells a software package that contains complex methods that another company wants to use in its own software product.



The Java platform provides an enormous API. Its packages represent the tasks most commonly associated with general-purpose programming.

For example:

  • a String object contains state and behavior for character strings;
  • a File object allows a programmer to easily create, delete, inspect, compare, or modify a file on the filesystem;
  • a Socket object allows for the creation and use of network sockets;
  • various GUI objects control buttons and checkboxes and anything else related to graphical user interfaces.

There are literally thousands of classes to choose from. This allows you, the programmer, to focus on the design of your particular application, rather than the infrastructure required to make it work.

As a programmer, The Java Platform API Specification will become your single most important piece of reference documentation. contains the complete listing for all packages, interfaces, classes, fields, and methods supplied by the Java Platform 6, Standard Edition


@API(since = "1.22", status = API.Status.EXPERIMENTAL)
public interface Closeable extends AutoCloseable {
  // override, removing "throws"
    @Override void close();

Documentation / Reference

Powered by ComboStrap