/*
Comparison operators:
==,!=,>,>=,<,<=
Characteristics:
Whether your operation is simple or complex, the result is a Boolean type.
Precautions:
"=" cannot be written as "=".
*/
1 classOperatordemo {2 Public Static voidMain (string[] args) {3 intx = 3;4 inty = 4;5 intz = 3;6 7SYSTEM.OUT.PRINTLN (x = =y);8SYSTEM.OUT.PRINTLN (x = =z);9System.out.println ((x+y) = = (x+z));TenSystem.out.println ("------------"); One ASYSTEM.OUT.PRINTLN (x! =y); -SYSTEM.OUT.PRINTLN (x >y); -SYSTEM.OUT.PRINTLN (x >=y); theSYSTEM.OUT.PRINTLN (x <y); -SYSTEM.OUT.PRINTLN (x <=y); -System.out.println ("------------"); - + intA = 10; - intb = 20; + A //Boolean flag = (A = = B); at //Boolean flag = (A = b);//This is problematic, incompatible type - //System.out.println (flag); - - intc = (A = b);//assign B to a and leave a behind. - System.out.println (c); - } in}
Java Note 4 comparison operators