Show 例子 2
优质
小牛编辑
134浏览
2023-12-01
以下程序是演示关系运算符的简单示例。 将以下Java程序复制并粘贴到Test.java文件中,然后编译并运行该程序。
例子 (Example)
public class Test {
public static void main(String args[]) {
int a = 10;
int b = 20;
System.out.println("a == b = " + (a == b) );
System.out.println("a != b = " + (a != b) );
System.out.println("a > b = " + (a > b) );
System.out.println("a < b = " + (a < b) );
System.out.println("b >= a = " + (b >= a) );
System.out.println("b <= a = " + (b <= a) );
}
}
这将产生以下结果 -
输出 (Output)
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false