Van icon

JAVA OPERATORS

Links


    //JAVA <
    public class A00_Operators {
    int x = 10;
    int y = 20;
    
    //1-Assignement Operators
    //2-Comparison Operators
    //3-Logical Operators
    
    
    //1-Assignement Operators
    public void AssignementOperators(){
    //Assignment
    x = 10;
    
    //Adition Assignment: The addition assignment operator (+=) adds a value to a variable:
    x += 5;
    x -= 2;
    x *= 6;
    x /= 9;
    }
    
    
    //2-Comparison Operators
    public void ComparisonOperators(){
    //equal to
    if(x == y) {x+=10;}
    
    //Not equal
    if(x != y) {x+=10;}
    
    //Greater than
    if(x > y) {x+=10;}
    
    //Less than
    if(x < y) {x+=10;}
    
    //Greater than or equal to
    if(x >= y) {x+=10;}
    
    //Less than  or equal to
    if(x <= y) {x+=10;}
    }
    
    
    //3-Logical Operators
    public void LogicalOperators(){
    //Logical and
    if((x <= y) && (x>100)) {x+=10;}
    
    //Logical or
    if((x <= y) || (x>100)) {x+=10;}
    
    //Logical not
    if (!(x <= y) || (x>100)) {x+=10;}
    }