简体   繁体   English

添加括号以明确运算符优先级

[英]Add parentheses to make operator precedence explicit

On SonarQube build it gives this Error where it says to "add parentheses to make operator precedence explicit in return statement".在 SonarQube 构建它给出了这个错误,它说“添加括号以使运算符优先级在return语句中显式”。 I am not sure whether to add the parentheses for ||我不确定是否要为||添加括号first or && .首先或&&

    }

&& has higher precedence than || &&的优先级高于|| , so to keep the same behavior add them around the && bit. ,所以为了保持相同的行为,在&&位周围添加它们。

return ShareClass.A.getAltName().equalsIgnoreCase(product.getShareClass().getValue()) ||
        (PcsProductLogicUtil.isUSMutualFund(product) && ShareClass.A.getName().equalsIgnoreCase(product.getShareClass().getValue()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM