What is the use of static import ?

Answer Posted / qamrun nisa

The static import construct allows unqualified access to
static members without inheriting from the type containing
the static members. Instead, the program imports the
members, either individually:

import static java.lang.Math.PI;

or en masse:

import static java.lang.Math.*;

Once the static members have been imported, they may be used
without qualification:

double r = cos(PI * theta);

The static import declaration is analogous to the normal
import declaration. Where the normal import declaration
imports classes from packages, allowing them to be used
without package qualification, the static import declaration
imports static members from classes, allowing them to be
used without class qualification.

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is java platform independent?

572


What is classes in java?

523


What is reverse function?

578


What's the base class of all exception classes?

569


How to provide security in java

1805






What restrictions are placed on method overriding?

644


What is a pattern what is an anti pattern?

512


Can we force garbage collector to run ?

574


What is compareto () in java?

544


Explain about member inner classes?

594


explain the difference between jdk and jvm?

564


What is pangram in java?

517


What is protected access modifier?

584


What about main() method in java ?

570


What is main function purpose?

529