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?
语法明智的是
collateral = autoCollateral!=null ? autoCollateral : secureCollateral
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.