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

Learn More

Java Operators - Assignment operators

Forked from Java Operators - Bitwise operators.

114 Runs 446 Views 119 Copies
Saved

Saved

gtsolutions 373

gtsolutions
published 4 years ago

    /*
    * Java Operators - Assignment operators
    */
    
    public class HelloWorld {
     public static void main(String args[]) {
         int a = 10;  
         int b = 20;
         int c = 0;
    
         c = a + b;
         System.out.println("c = a + b = " + c );
         
         c += a ;
         System.out.println("c += a  = " + c );
    
         c -= a ;
         System.out.println("c -= a = " + c );
    
         c *= a ;
         System.out.println("c *= a = " + c );
    
         a = 10;
         c = 15;
         c /= a ;
         System.out.println("c /= a = " + c );
    
         a = 10;
         c = 15;
         c %= a ;
         System.out.println("c %= a  = " + c );
    
         c <<= 2 ;
         System.out.println("c <<= 2 = " + c );
    
         c >>= 2 ;
         System.out.println("c >>= 2 = " + c );
    
         c >>= 2 ;
         System.out.println("c >>= a = " + c );
    
         c &= a ;
         System.out.println("c &= 2  = " + c );
      
         c ^= a ;
         System.out.println("c ^= a   = " + c );
    
         c |= a ;
         System.out.println("c |= a   = " + c );
      }
    }
    
    
    
    Please login/signup to get access to the terminal.

    Your session has timed out.

    Dismiss (the page may not function properly).