如何在Java 9的JShell中实现关系和逻辑运算符?

如何在Java 9的JShell中实现关系和逻辑运算符?

The relational operators (==, != , =) can be used mainly for comparison. It accepts operands of non-boolean primitive data types and returns a boolean value. JShell also supports logical operators that can be used in expressions. The logical operators can expect boolean operands. The expressions involving these operands can be used for forming boolean conditions in the code within if, for, and while statements. The logical operators include : "&& : logical AND", "|| : OR" and "! : NOT".

In the below two code snippets, we can implement relational operators using JShell.

Snippet-1

jshell> int i = 10; i ==> 10 jshell> i > 10; $2 ==> false jshell> i >= 10; $3 ==> true jshell> i false jshell> i true jshell> i == 10; $6 ==> true jshell> i == 20; $7 ==> false登录后复制