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

What is flag in python?

772


Explain the difference between string, stringbuffer and stringbuilder in java?

734


What is the latest java version?

773


How can u increase the heap size in the memory?

747


Why collection doesn’t extend cloneable and serializable interfaces?

850


How many types of variables are there?

867


Explain the private field modifier?

826


What is the use of arrays tostring () in java?

711


What are 3 boolean operators?

712


Which is a valid identifier?

738


Why java is not 100% object-oriented?

1146


How do you allocate memory to object?

703


What is application tier?

746


What is floor math?

674


What are dot operator queries?

831