The Java Application Programming Interface (API)

Read this article, which describes the Java Application Programming Interface (API). The Java API is a list of all classes that are part of the Java Development Kit (JDK). It includes all Java packages, classes, and interfaces, along with their methods, fields, and constructors. These pre-written classes provide a tremendous amount of functionality to programmers, and you should be aware of these classes and should know how to use them.

A complete listing of all classes in Java API can be found at Oracle’s website: http://docs.oracle.com/javase/8/docs/api/index.html

Visit this site and bookmark it for future reference. Consult this site often, especially when you are using a new class and would like to know more about its methods and fields. If you browse through the list of packages in the API, you will see packages written for GUI programming, networking programming, managing input and output, database programming, and many more. Take some time to browse the complete list of packages and their descriptions to see how they can be used.

In order to use a class from Java API, you need to include an import statement at the start of the program. For example, in order to use the Scanner class, which allows a program to accept input from the keyboard, you need to include the following import statement:

import java.util.Scanner;

This import statement allows you to use any method listed in the Scanner class. Another choice for including the import statement is the wildcard option: 

import java.util.*;

This version of the import statement imports all the classes in the API’s java.util package and makes them available. If you check the API and look at the classes written in the java.util package, you will see that it includes some of the classes that are used often, such as Arrays, ArrayList, Formatter, Random, and many others.

Another Java package that has several commonly used classes is the java.lang package. This package includes classes that are fundamental to the design of Java language. The java.lang package is automatically imported in a Java program and does not need an explicit import statement. Some of the classes that we use very early in Java programming come from this package. Commonly used classes in the java.lang package are: Double, Float, Integer, String, StringBuffer, System, and Math.

Last modified: Monday, November 6, 2017, 1:29 PM