Question: I have a static reference variable 

```
static IMail mailer = null;

```

to which I am assigning a value in the constructor of the class SearchManager

```
public SearchManager(ILog logger, String basePath, String indexPath, String nwId, IMail mailer) {
        this.logger = logger;
        this.basePath = basePath;
        this.indexPath = indexPath;
        this.nwId = nwId;
        this.mailer = mailer;
    } 

```

and I am using the mailer in my code. The constructor of this class might be called multiple times. So I have a query that how this static reference variable will behave each time the constructor is called. Will it take only the value which I passes when I called the constructor the first time or will it take different values each time I call the constructor?

Answer: 
First of all you **should not use 'this' keyword with static variable**. You can do the following(not recommended though)

```
public SearchManager(ILog logger, String basePath, String indexPath, String nwId, IMail mailerarg) {
        this.logger = logger;
        this.basePath = basePath;
        this.indexPath = indexPath;
        this.nwId = nwId;
        mailer = mailerarg;
    } 

```

and **Yes it being a static variable will change every time you create a new object of the Class**.Static variables belong to Class rather than it's individual instances. So whenever you change it's value it will be reflected in all the corresponding class objects(All objects have their class information).
> 
> Will it take only the value which I passes when I called the constructor the first time or will it take different values each time I call the constructor?
> 
> 
> 

It will take different values as it is shared by the instances, and each instance will see the same value off course.

As per the [JLS 8.3.1.1](http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.3.1.1):

> 
> If a field is declared static, there exists exactly one incarnation of the field, no matter how many instances (possibly zero) of the class may eventually be created. A static field, sometimes called a class variable, is incarnated when the class is initialized
> 
> 
>