fundamental Code Samples
- How do I use the boolean negation (!) operator in Java?
- How do I create enumerations type?
- How do I use the this keyword in Java?
- How do I create a class in Java?
- How do I get constants name of an enum?
- How do I use the final keyword in Java?
- How do I use the do-while loop statement?
- How do I use the while loop statement?
- How do I use the return keyword in Java?
- How do I define a constant variable?
- How do I use the switch statement?
- How do I catch multiple exceptions?
- How do I create static variables in Java?
- How do I create and implement abstract class?
How do I use the unary operators?
The unary operators requires only one operand to operate on, it can perform operations such as incrementing or decrementing value by one, negating a value or inverting a value of a boolean expression.
The unary operators use the following symbols:
+ |
unary plus operator; indicates positive value |
- |
unary minus operator; negates a value |
++ |
unary increment operator; increments value by one |
-- |
unary decrement operator; decrements value by one |
! |
unary logical complement operator; inverts a boolean value |