Explain the various shorthand notations in JAVA.
Advertisements
प्रश्न
Explain the various shorthand notations in JAVA.
स्पष्ट कीजिए
Advertisements
उत्तर
- Addition Assignment (
+=): This operator adds the specified value to the existing value of a variable and assigns the result to the same variable.
Example:a += 5;is equivalent toa = a + 5; - Subtraction Assignment (
-=): This operator subtracts the specified value from a variable and assigns the result to the same variable.
Example:a -= 5;is equivalent toa = a - 5; - Multiplication Assignment (
*=): This operator multiplies the existing value of a variable by the specified value and stores the result in the same variable.
Example:a *= 5;is equivalent toa = a * 5; - Division Assignment (
/=): This operator divides the existing value of a variable by the specified value and assigns the result to the same variable.
Example:a /= 5;is equivalent toa = a / 5; - Modulus Assignment (
%=): This operator calculates the remainder after dividing a variable by the specified value and assigns the remainder to the same variable.
Example:a %= 5;is equivalent toa = a % 5; - Increment Operator (
++): This operator increases the value of a variable by one.
Example:a++;is equivalent toa = a + 1; - Decrement Operator (
--): This operator decreases the value of a variable by one.
Example:a--;is equivalent toa = a - 1;
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]
