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 [पृष्ठ १३१]
