0

I have 2 string variables autoCollateral and secureCollateral. I need to set the value of collateral to have the value of the variable that has a non-null value.

I wrote the code as

if(autoCollateral!=null){
  collateral=autoCollateral
} 
if(secureCollateral!=null){
  collateral=secureCollateral
}.

If both has value I need to set any of them...what is the most optimized way to do this?

4

1 に答える 1

5

構文的には

collateral = autoCollateral!=null ? autoCollateral : secureCollateral
于 2013-06-29T05:08:12.050 に答える