gpt4 book ai didi

java - Beanshell 不等于声明

转载 作者:行者123 更新时间:2023-11-30 07:36:53 26 4
gpt4 key购买 nike

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

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

最佳答案

使用 ! 一元 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)

相关问题

关于java - Beanshell 不等于声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3179359/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com