Static import : Static Import « Class Definition « Java Tutorial






In Java 5 you can import static fields using the import static keywords.

Before Java 5, to use a static final field in the Calendar class, you must first import the Calendar class.

import java.util.Calendar;

Then, you can use it by using the notation className.staticField.

if (today == Calendar.SATURDAY)

In Java 5, you can do

import static java.util.Calendar.SATURDAY;

if (today == SATURDAY)








5.31.Static Import
5.31.1.Static import
5.31.2.Static importing the Math Class Methods
5.31.3.Use static import to bring sqrt() and pow() into view.