Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What is static import in Java?
As import statement allows to use a class without its package qualification, static import allows to access the static members of a class without class qualifications. For Example, to access the static methods you need to call the using class name −
Math.sqrt(169);
But, using static import you can access the static methods directly.
Example
import static java.lang.Math.*;
public class Sample{
public static void main(String args[]){
System.out.println(sqrt(169));
}
}
Output
13.0
Advertisements
