I saw some code over the web like:
import static org.mockito.Mockito.*;
Can someone please tell me what this static means in this case?
I saw some code over the web like:
import static org.mockito.Mockito.*;
Can someone please tell me what this static means in this case?
In order to access static members, it is necessary to qualify references with the class they came from. For example, one must say:
double r = Math.cos(Math.PI * theta);
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);
There is the source here.
You might write the following code:
staticMethod();
instead of:
Mockito.staticMethod();