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: 
> 
> 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 each time you call the constructor.

Static variables are not particularly special. When you assign a value to variable, the variable takes that value. This is equally true of static variables, so if you assign a static variable multiple times, its value will be updated each time.

---

In this case, if you're calling a contructor (potentially) multiple times with different arguments, it sounds very much like this should be an instance-spceific field, rather than a single static variable. That way, each `SearchManager` has a reference to the `mailer` that *it* was constructed with, rather than the mailer of the manager that happened to be constructed most recently.

Even if you don't agree with this, and feel that there should be a single `mailer` for the whole application, I would suggest you change the way it's currently managed. Values passed into constructors tend to be used for *that* instance. Setting static variables in constructors is thus potentially very confusing, and it would be better to make an explicit call to something like `MailerSupport.setGlobalMailer(mailer)` instead whenever you wanted to change the value.
Value can be changed any time, but all instance have same and latest values.ie last time called