Operators textbook series (two) - Java relational operators

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
        
}
}
Published 32 original articles · won praise 182 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_44092440/article/details/102971022