# JAVA programs

## Java Program Using Compound assignment operator

`In this program we see the use of the Compound assignment operator like `
`+= (compound addition assignment operator) `
`/= (compound division assignment operator)`
`%= (compound modulo assignment operator)`
`-=  (compound subtraction assignment operator)`
`*= (compound multiplication assignment operator)`
`&= (compound Bitwise & assignment operator)`

## Program

//Program Using Compound assignment operator

class CompAssignDemo

{

public static void main(String[] args)

{

int x=5;

int y=10;

x+=y;

x-=y;

System.out.println("The substraction is:"+x);

x*=y;

System.out.println("The multiplication is:"+x);

x/=y;

System.out.println("The division is:"+x);

x%=y;

System.out.println("The remainder is:"+x);

x&=y;

System.out.println("The result of AND operation:"+x);

x|=y;

System.out.println("The result of Bitwise inclusive OR operation:"+x);

x<<=y;

System.out.println("The result signed LEFT shift operation:"+x);

}

}

## When Run The Program Following Output:

The substraction is:5

The multiplication is:50

The division is:5

The remainder is:5

The result of AND operation:0

The result of Bitwise inclusive OR operation:10

The result signed LEFT shift operation:10240 ## Description

Compound assignment operator provides a shorter syntax for assigning the result of an arithmetic or bitwise operator that is useful for reduce the code and perform desire operation. They perform the operation on the two operands before assigning the result to the first operand. That means the operation performs between two operands and result save in first operand so we doesn’t have need to use third variable, That save memory space.

## Releted Programs

 Program Using Arithmetic Operator Java program for classes and object Program Using if else statement Java Program Using Compound assignment operator Java Program for print alphabet on screen java program using break statement program using bitwise operator Program to find greater no between three numbers Java Program Using if statement Java Program Using do while loop