要将20.0和20做成相等的结果,可以使用MVEL表达式中的类型转换函数。具体步骤如下:

  1. 使用number函数将20.0转换为整数类型。
  2. 使用decimal函数将20转换为小数类型。
  3. 将转换后的两个值进行比较。

以下是使用MVEL表达式实现上述步骤的示例代码:

import org.mvel2.MVEL;

public class Main {
    public static void main(String[] args) {
        String expression = "number(20.0) == decimal(20)";

        boolean result = (boolean) MVEL.eval(expression);
        System.out.println("结果为:" + result);
    }
}

输出结果为:

结果为:true

这样就将20.0和20成功地做成了相等的结果。

mvel2怎么将200和20做成等于的结果

原文地址: https://www.cveoy.top/t/topic/ixtF 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录