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

When can an object reference be cast to an interface reference in java programming?

579


Explain different forms of polymorphism?

653


explain autoboxing in java?

594


What is a constructor overloading in java?

522


What is the difference between stream and buffer?

515






Can an interface extend a class?

538


What is the purpose of final keyword and when to use it?

524


What is synchronization and why is it important in java programming?

469


What is a modifier?

865


What are the 3 types of control structures?

527


What happens if we don’t define serial version uid?

569


4.1 Supply contracts (in the form of comments specifying pre- and post conditions) for the enqueue() method of the LinkedQueue class given in the Appendix. (2) 4.2 Let Thing be a class which is capable of cloning objects, and consider the code fragment: Thing thing1 = new Thing(); //(1) Thing thing2 = thing1; //(2) Thing thing3 = (Thing) thing1.clone(); //(3) Explain how the objects thing2 and thing3 differ from each other after execution of the statements. (

1407


Explain treeset?

591


How to set the permissions to a file in java?

535


Can you override a final method?

578