Java关系运算符示例
下面的简单示例程序演示了关系运算符。复制并粘贴到Test.java的文件中的以下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