Login with  Log in with facebook
Hiring Manager? SIGN UP HERE

What are static imports in Java.

Rishi Yadav
08/10/2011 at 22:41
2 Answers

whenever you want  to import all the static methods of a particular class then you can use static import...

Ashish Bhargawa
08/12/2011 at 10:44


Normal imports are used for classes, interfaces, enums and annotations, whereas, static imports are used for static members of any class, interface or enum.

eg. we can use

import static java.lang.Math.PI;

so that we can use PI instaead of the fully qualified form of java.lang.Math.PI or Math.PI.

we also use wild cards like

import static java.lang.Math.*;

so that we can use simply cos, sin, min, max, which are static methods instead of writing their fully qualified forms.


Pravin Jain
08/27/2011 at 11:26

If you want to post any answer to this forum then you need to log in.
Schedule a Demo

Schedule a Demo with us

Name *
Email *
Phone *
Company *