String input = sc.nextLine();
System.out.println(Boolean.parseBoolean(input));
所以我投入的样子1 > 2
或false || true
,但我没有得到正确的价值观。使用字符串输入布尔
但是,当我打电话:
Boolean x = 1 < 2;
System.out.println(x);
我让他们正确的。所以我的问题是。 如何将字符串输入转换为返回布尔值?
到目前为止已经试过:
Boolean.parseBoolean();
Boolean.getBoolean();
Boolean.valueOf();
谢谢您的回答。
编辑
INPUT - OUTPUT
1 < 2 - false(should be true)
false || true - false(should be true)
执行代码时你获得了什么值?请在此分享。 –