The assignment to variable [Something] has no effect [closed]

I get this warning, what does it mean?

The assignment to variable name has no effect.

I also get the same error for all 3 fields. The full code is below:

public class Module {

    private String name;
    private int bind;
    private Category category;

    public Module(String name,int bind,Category category) {
    }{
        this.name = name; // The assignment to variable name has no effect
        this.bind = bind;
        this.category = category;
    }

Answer

Here is your problem, extra braces:

public Module(String name,int bind,Category category) {
}{ // <<<
    this.name = name;
    this.bind = bind;
    this.category = category;
}

It should be:

public Module(String name,int bind,Category category)
{
    this.name = name;
    this.bind = bind;
    this.category = category;
}

Leave a Reply

Your email address will not be published. Required fields are marked *