Speed up development with full-stack environments for every branch.

Learn More

Java Operators - Arithmetic operators

Forked from Basic Java Example.

127 Runs 707 Views 158 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

    /*
    * Java Operators - Arithmetic operators
    */
    
    public class HelloWorld {
      public static void main (String[] args){
             
            // result is now 3
            int result = 1 + 2;
            System.out.println(result);
    
            // result is now 2
            result = result - 1;
            System.out.println(result);
    
            // result is now 4
            result = result * 2;
            System.out.println(result);
    
            // result is now 2
            result = result / 2;
            System.out.println(result);
    
            // result is now 10
            result = result + 8;
            // result is now 3
            result = result % 7;
            System.out.println(result);
        }
    }
    
    
    
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).