有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Beanshell不相等语句

什么是beanshell中的if not equal语句?如果这是相等的:

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

共 (1) 个答案

  1. # 1 楼答案

    使用!一元数boolean逻辑补码运算符:

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

    参考文献

    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.


    测试if (!something)的另一个选项是测试if (something == false)

    相关问题