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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -