Operators textbook series (two) - Java relational operators
More, click here to learn, sign up for
Relational operators: compare the relationship between two variables
Greater than
= greater than or equal to
<Less than
<= Less than or equal to
== equality
= if unequal!
Step 1: relational operators
Step 2: Practice - relational operators
Step 3: Answer - relational operators
Example 1: Relationship operator
greater than
= greater than or equal to
<Less than
<= Less than or equal to
== is equal
! = whether unequal
public class HelloWorld {
public static void main(String[] args) {
int a = 5;
int b = 6;
int c = 5;
System.out.println(a>b); //返回 false
System.out.println(a>=c); //返回 true
System.out.println(a==b); //返回false
System.out.println(a!=b);//返回true
}
}