java - Use of || operator for alternative assignment -
in javascript, may define:
num = numerator || 0; denom = denominator || 1;
yet, in java, cannot applied.
without using conditionals (explicitly written), there concise way achieve "if undefined, assign this"?
maybe enough.
num = numerator != null ? numerator : 0; denom = denominator != null ? denominator : 1;
Comments
Post a Comment