Explain the following with an example segment: Unary Operator
Advertisements
प्रश्न
Explain the following with an example segment:
Unary Operator
कोड लेखन
स्पष्ट कीजिए
Advertisements
उत्तर
A Unary Operator in Java is an operator that performs an operation on a single operand. It is used to increase, decrease, negate or change the value of an operand.
Common unary operators include increment (++), decrement (--), unary plus (+), unary minus (-) and logical NOT (!).
Example Code Segment:
int a = 10;
System.out.println(++a);
System.out.println(--a);
Output:
11
10
10
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]
