As the name indicates unary Operators act on only one operand.There are 3 kinds of unary operators

  1. uniary minus operator(-)
  2. Increment operator(++)
  3. Decrement operator(–)

Unary minus operator

This operator is used to negative a given value.

تعليم تداول الاسهم Example:

public class Test {
	public static void main(String[] args) {
		int x=5;
		System.out.println(-x);
		System.out.println(-(-x));
	}
}
/*
Output:
-5
 5
*/

Increment operator(++)

  1. Writing ++ before a variable is called “ إيزي فوركس Pre incrementation
  2. Writing ++ after a variable is called “ http://blng.co.za/?rtio=%D8%A7%D9%84%D8%AA%D8%AF%D8%A7%D9%88%D9%84-%D8%B9%D9%86-%D8%B7%D8%B1%D9%8A%D9%82-%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D8%B1%D9%86%D8%AA&f02=6b التداول عن طريق الانترنت Post incrementation

In pre incrementation ,Incrementation is done first and any other operation is done next.
In post Incrementation ,all other operations are done first and incrementation is one only at the end.

public class Test {
	public static void main(String[] args) {
		int x=1;
		System.out.println(x); 
		System.out.println(++x);
		System.out.println(x); 
	}
}
/*
Output:
 1
 2
 2
*/

http://mountainreformed.com/cialis-online-cost اسهم البنك العربي Example:

public class Test {
	public static void main(String[] args) {
		int x=1;
		System.out.println(x);
		System.out.println(x++);
		System.out.println(x);
	}
}
/*
Output:
 1
 1
 2
*/

http://www.fonctionsoptimum.com/?fokys=%D8%A8%D9%8A%D8%B9-%D8%A7%D8%B3%D9%87%D9%85-%D8%A8%D8%A7%D9%84%D8%B1%D8%A7%D8%AC%D8%AD%D9%8A&fb5=43 بيع اسهم بالراجحي Example:


public class Test {
	public static void main(String[] args) {
		int a=1,b=2;
		a=++b;
		System.out.println(a);//3
		System.out.println(b);//3
	}
}
/*
Output:
 3
 3
*/

http://www.pk.adv.br/?asder=%D8%A7%D9%81%D8%B6%D9%84-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85-%D9%81%D9%8A-%D8%A7%D9%84%D8%A7%D9%86%D8%AA%D8%B1%D9%86%D9%8A%D8%AA&e58=77 افضل الاسهم في الانترنيت Example:

public class Test {
	public static void main(String[] args) {
		int a=1,b=2;
		a=b++;
		System.out.println(a);
		System.out.println(b);
	}
}
/*
Output:
 2
 3
*/

Decrement Operator(- -)

This operator is used to decrement the value of a variable by 1.

  1. Writing – -before variable is called forex växlingskontor solna pre-decrementation.
  2. Writing – -after variable is called pre-decrementation.

giełdy inwestycyjne Example:

public class Test {
	public static void main(String[] args) {
		 int x=5;
		 System.out.println(--x);
		 System.out.println(x--);
	}
}

/*
Output:
 4
 4
*/
Expression Initial value of x Final value of y Final value of x
y=++x 4 5 5
y=x++ 4 4 5
y=- -x 4 3 3
y=x- – 4 4 3
  1. Increment/Decrement operators applicable only for variables but not for constant values
  2. اسعار الذهب مباشر في السعودية Example:

    
    public class Test {
       public static void main(String[] args) {
    	int x=4;
    	int y=++x;
    	System.out.println(x);
    	System.out.println(y);
       }
    }
    /*
    Output:
     5
     5
    */
    

    http://investingtips360.com/?klaystrofobiya=%D8%A8%D9%86%D9%83-%D8%B3%D8%A7%D9%85%D8%A8%D8%A7-%D8%A8%D9%8A%D8%B9-%D8%A7%D9%84%D8%A7%D8%B3%D9%87%D9%85&f85=ee بنك سامبا بيع الاسهم Example:

    
    public class Test {
      public static void main(String[] args) {
    	int y=4++;//C.E
    	System.out.println(y);
      }
    }
    /*
    Output:
    Compile time error: Unexpected type
    required:variable
    found :value
    */
    
  3. We can’t nest increment and decrement operators.
    bonus di benvenuto senza deposito forex Example:

    
    public class Test {
      public static void main(String[] args) {
    	int x=4;
            int y=++(++x);//C.E
            System.out.println(y);
      }
    }
    /*
    Compile time error:Unexpected type
    required:variable
    found :value
    */
    
  4. we cannot increment/decrement final variables.
    تجارة الذهب المستعمل Example:

    public class Test {
      public static void main(String[] args) {
    	final int x=4;
            x++;//C.E
            System.out.println(x);
     }
    }
    /*
    Compile time Error:Cannot assign a value to final variable x.
    */
    
  5. we can apply increment/decrement operators even for floating point data types also.
    اسعار الذهب في المملكة العربية السعودية اليوم Example:

    public class Test {
      public static void main(String[] args) {
    	float d=10.5f;
    	d++;
    	System.out.println(d);
      }
    }
    /*
    Output:
    11.5
    */
    

    online forex trading in philippines Output:11.5

Difference between b++ and b=b+1?

When ever we are applying arithmetic operation b/n two operands a and b the result type is:max(int,type of a,type of b);

كيف تجارة الاسهم Example:

public class Test {
	public static void main(String[] args) {
		  byte a=10;
		  byte b=20;
		  byte c=a+b; //max(int,byte,byte)=int
		  System.out.println(c);
	}
}
/*
Compile time error:Possible loss of precision
found:int
required:byte
*/

In the case of increment/decrement operators, internal type casting is performed by the compiler hence ,b++=>(type of b)(b+1)
Example:


public class Test {
public static void main(String[] args) {
  byte b=10;
  b++;
  System.out.println(b);
 }
}
/*
Output:
11
*/

Example:


public class Test {
	public static void main(String[] args) {
		byte b=10;
		b=b+1;//C.E
		System.out.println(b);
	}
}

/*
Compile time error:Possible Loss of precision
found:int
required:byte
*/