Java Static Import

Last Updated : 4 Apr 2026

Java static import allows direct access to static members of a class without using the class name.

In this chapter, you will learn about Java static import, how it works, and its advantages and disadvantages.

What is Java Static Import?

Static import is a feature introduced in Java 5 that allows programmers to access static members (variables and methods) of a class directly, without qualifying them with the class name.

The static import reduces code length when static members are used frequently.

Creating Static Import

To use static import, we use the import static keyword followed by the class name and the static member.

Syntax:

It has the following syntax:

If you want to import all static members of a class, you can use the wildcard *:

Using static import allows you to access static methods and variables directly without using the class name.

Examples of Java Static Import

The following examples demonstrate how to use static import in Java.

Example 1: Static Import of a Specific Member

In this example, we import a specific static method and use it directly without the class name.

Output:

4.0

Example 2: Static Import of All Members

In this example, we import all static members of a class using * and use them directly.

Output:

5.0
8.0

Difference Between Import and Static Import

The import statement allows programmers to access classes and interfaces from a package without using the full package name.

The static import allows direct access to static members (variables and methods) of a class without using the class name.

In short, import is used for classes and interfaces, while static import is used for static members of a class.

Next TopicJava 8 Features