mercredi 14 octobre 2015

Implementing enable/disable method in Java [on hold]

Which is the better way to implement a enable/disable method in Java?

1:

private boolean flag;

public void enable(boolean enable) {
    flag = enable;
}

2:

private boolean flag;

public void enable() {
    flag = true;
}

public void disable() {
    flag = false;
}

Are there better wayys to do it?

Aucun commentaire:

Enregistrer un commentaire