I have many classes extending from a base class which has this function:
public boolean setVal(int v) {
if (val != v) {
val = v;
return true;
}
return false;
}
Since I have so many classes, I would like to make this statement as efficient as possible. I've tried this:
public boolean setVal(int v) {
return val == v ? false : (val = v | true);
}
However, I guess I can not change val
inline like this. (I'm very new to Java)
Can this be made more efficient?
Aucun commentaire:
Enregistrer un commentaire