Use of Boolean? in if expression

前端 未结 11 1899
陌清茗
陌清茗 2020-12-13 23:14

If I have a nullable Boolean b, I can do the following comparison in Java:

Boolean b = ...;
if (b != null && b) {
   /* Do something */
         


        
11条回答
  •  情书的邮戳
    2020-12-13 23:52

    In case if you want to perform operations alike contain on a String you could use equality check like below -

    if (url?.contains("xxx") == true){
      return false;
    }
    

提交回复
热议问题