Operator in Java Program-4

Operator in Java Program – 4

Operator is very import for all languages. Operator can calculate, check, assign, increase and decrease the value of variable. So operator is heart of java program. I give simple example of operator in program.

“X = Y”;

In this example ans, Y and X are variable;

= (assignment) operators. “

So we can easily understand the import of operator in java program language. In this blog we will discuss on Assignment [ = ] operators and its sub operator like Arithmetic assignment, bitwise assignment operator.

  1. Assignment operator

= is symbol of Assignment operator.

Using of this operator we can store value from one variable to another variable.

Let’s take simple example.

int x = 10;

int y = x;        // Here x assigns its value to y variable.

  1. Sub part of assignment operator

Arithmetic assignment, bitwise assignment operator are part of this sub part.

Let’s take simple example.

int x = 10;

x = x+2;         // this is simple statement

x+=2;             // this is arithmetic assignment statement

Here both statements are valid in program.

 

Program on Assignment Operator:

class op4

{

          public static void main(String args[])

          {

                   int x = 50;

                   int y = x;     // x assigns its value to y , y = 50

                   System.out.println(“Y = ” + y);

                   // x = x * 2;

                   x*=3;           // This is call Arithmetic Assignment operator

                   System.out.println(“X = ” + x);        // X = 100

          }

}

Output:

Y = 50

X = 100

 

Video available on YouTube.

 


[sbscrbr_form]

If you have problem on this blog, you can directly comment or subscribe on website.


Earn money online

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS

176total visits,1visits today


mayank

Hello, I am Maddy a Java blogger, trainer and developer

Related articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Your comments (*)

Name (*)

Your full name please.

Email address (*)

Used for gravatar.

Website

Link back if you want.

EmailEmail
PrintPrint