Java 关系运算符示例
以下程序是一个演示关系运算符的简单示例。复制并粘贴以下Java程序到Test.java文件中,然后编译并运行该程序。
示例
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) );
}
}
这将产生以下结果−
输出
a == b = false
a != b = true
a > b = false
a < b = true
b >= a = true
b <= a = false