I have two strings str1
and str2
. Check both of them and see if any one string is empty.
If yes, then replace that str with another one.
if(indexOf(str1) < -1 || indexOf(str2) < -1){
str1 = str2;
}
will this work?
No, that won't work for numerous reasons. This will though:
if(!str1)
str1 = str2;
else if(!str2)
str2 = str1;
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.