0

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

0

2 Answers 2

1

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) {
Sign up to request clarification or add additional context in comments.

Comments

0

According the the documentation,

  1. The normal import declaration imports classes from packages, allowing them to be used without package qualification,
  2. The 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.

1 Comment

The question is a dupe. Dont be a rep monger.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.