save up to 40%

What are assignment operators?

Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.

What are assignment operators?

Rating:

There are two forms of assignment operators used in expressions. The first one is called the simple assignment operator and the other one is called the compound assignment operator.

  1. Simple assignment operator: The simple assignment operator assigns the left operand with the value of the right operand.


  2. Compound assignment operator: The compound assignment operator first performs the desired operation between the left and right operands and then assigns the result to the left operand. The compound assignment operator takes the form as given below:

    Syntax:

    x op= y

    The above syntax is equivalent to the following:

    x = x op y

    Following is the list of compound assignment operators available in Java:

    OperatorNameUseDescription
    +=Addition assignmentx+=yassigns x with the value of x+y
    -=Subtraction assignmentx-=yassigns x with the value of x-y
    *=Multiplication assignmentx*=yassigns x with the value of x*y
    /=Division assignmentx/=y assigns x with the value of x/y
    %=Modulus assignmentx%=yassigns x with the value of x%y
    &=Bitwise AND assignmentx&=yassigns x with the value of x&y
    |=Bitwise OR assignmentx|=yassigns x with the value of x|y
    ^=Bitwise exclusive OR assignmentx^=yassigns x with the value of x^y
    <<=Shift left assignmentx<<=yassigns x with the value of x<<y
    >>=Shift right assignmentx>>=yassigns x with the value of x>>y
    >>>=Shift right zero fill assignmentx>>>=yassigns x with the value of x>>>y


Rating:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us | News and Press Release | uCertify India
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.