What does static
mean in
import static org.mockito.Mockito.*;
I have seen statements like import java.util.*;
but it never had static.
Thank you
What does static
mean in
import static org.mockito.Mockito.*;
I have seen statements like import java.util.*;
but it never had static.
Thank you
static is a Java keyword (not specific to Mokito). Statically importing a class allows you to use class members from the imported class without qualification.
So instead of doing something like this:
if (foo == Answers.CALLS_REAL_METHODS) {
You can do:
if (foo == CALLS_REAL_METHODS) {
According the the documentation,
import
declaration imports classes from packages, allowing them to be used without package qualification, static
import
declaration imports static members from classes, allowing them to be used without class qualification.You can use it when you require frequent access to static members from one or two classes.