operator-in-java-masterskill

 Master Skill 

Operator in Java 

Java, java programmimg , java logo

java provide many operator , which can be used according to the need .they are classified based on the funtionality they provide.

"operator is java are the symbol used for performing specific operation in java. operator mask task like addition, multiplication e.t.c 

Type of Operator in java

There are multiple type of operation in java

  1. Arithmetic operation
  2. unary operator
  3. Assignment operator
  4. Relation operator
  5. logical operator
  6. Ternary operator
  7. Bitwise operator
  8. Shift operator
  9. Instance of Operator

Operator Of java , java operator,


Arithmetic Operator

They are used to perform "Simple Arithmetic Operation on Premitive data types.
  • Multiplicataion  (*)
  • Division (/)
  • Modulo(%)
  • addition(+)
  • Subsration(-)
For Example
// Arithematic operator
int a=10;
int b+3;
system .out.println("a+b="(a+b));
system .out.println("a-b="(a-b));
system .out.println("a*b="(a*b));
system .out.println("a/b="(a/b));
system .out.println("a%b="(a%b));
             }
    }

Output
 a+b=13
 a-b=7
 a*b=30
 a/b=3
 a%b=1

2. Unary Operator

Unary operator need only one Operand , They are used to Increment, decrement or negate value

*(-) unary Minus -> used for negative value
*(+) unary Plus -> used for number of positive

(+ +) increment operator
used for incrementing the value by 1. there are two increment operator 

~A. Post increment operator~
value is first used for computing the result and then incremented

~B. Pre increment operator~
value is incremented first, and than the result is computed

(- -) Decrement operator

A. Post decrement :-
value is first used for computing the result than drecremented

B. Pre- Decrement:- 
the value is decrement first and than the result is computed.

(!) logical Not operator 
Used for inverting a Boolean value

For example
      int a=10;
      int b=10

post increment=10
pre increment =12

post decrement=10
Pre decrement=8

3.Assignment operator (=)

is used to assignment a value to any variable . it has right to left associativity.
general format of the the assingnment  operator is
   
(Variable= value)
                             
                                 in many case (=) can be combined with other operator " are cllled compound statement"

For example


Instead (a=5) ya ( a+ =5 )
int x = 10;
x += 5;

 4. Logical operator

You can also test for true or false values with logical operators.

Logical operators are used to determine the logic between variables or values:


Operator Name Description Example

&& Logical and Returns true if both statements are true x < 5 &&  x < 10

|| Logical or Returns true if one of the statements is true x < 5 || x < 4

! Logical not Reverse the result, returns false if the result is true !(x < 5 && x < 10)




Comments

people like this

Disable-Knox-Tool-download

Explain-Java-Array-masterskill

Operators In java-masterskill