Unary Operators : Java Programming

Unary Operators in Java Programming :

  • The unary operators require only one operand.
  • There are 5 unary operators in Java Programming Language.

Unary Operators are :

Live Example : Unary Operator

class UnaryDemo {
    public static void main(String[] args){
        // result is now 1
        int result = +1;
        System.out.println(result);
        // result is now -1
        result = -result;
        System.out.println(result);
        // false
        boolean success = false;
        System.out.println(success);
        // true
        System.out.println(!success);
    }
}