开发者

Beanshell not equal statement

What is if not equal s开发者_C百科tatement in beanshell ? if this is equal :

if ("myVarValue".equals(vars.get("MY_VARIABLE")))


Use the ! unary boolean logical complement operator:

if (!"myVarValue".equals(vars.get("MY_VARIABLE")))

References

  • JLS 15.15.6 Logical Complement Operator !

The type of the operand expression of the unary ! operator must be boolean or Boolean, or a compile-time error occurs. The type of the unary logical complement expression is boolean.

At run time, the operand is subject to unboxing conversion if necessary; the value of the unary logical complement expression is true if the (possibly converted) operand value is false and false if the (possibly converted) operand value is true.


Another option for testing if (!something) is to test if (something == false).

Related questions

  • Is it bad to explicitly compare against boolean constants e.g. if (b == false) in Java?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜