Assignment Operators in Java program

One of the operators in java is the assignment operator that helps assign value to variables and other identifiers. This is a simple program to demonstrate and learn the basics of Java Programming. It is intended for beginners of Java language.

Advertisements

We are using JDK 8u111 with Netbean IDE 8.2 installed on a Windows 7 64-bit PC. Alternatively, you can compile and run Java from Windows Command line also.

Advertisements

Problem Definition

In this program, we will demonstrate the use of assignment operator. We declare and initialize the variable using different methods and display the output.

Program Code

class assign {

public static void main(String args[]) {
                        int a=1;
                        int b=2;
                        int c=3;

                        a += 5;
                        b *= 4;
                        c += a * b;
                        c %= 6;

                        System.out.println("a=" + a);
                        System.out.println("b=" + b);

                        System.out.println("c=" + c);

                    }

             }

Output – Assignment Operator

The output of the above program is given below.

a= 6

b= 8

c= 5

Advertisements

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.