Operators in Java

1
337
Spread the love
  • 24
  • 34
  • 14
  • 12
  •  
  •  
  •  
  • 10
  •  
  •  
    94
    Shares

Operators in Java:

An operator takes one or more arguments and produces a new value. The arguments are in little different from ordinary method calls but result in the same. All operators produce value from their operand. An operator can change the value of an operand. This is called a side effect. The most common use for operators that modify their operand is to generate the side effect. But the value produced is available for our use as in operators without side effects.

In general, operations mainly classified into two categories:

  1. Transitive
  2. Non-Transitive

When x(operator)y(operator)z=z(operator)y(operator)x then the operation is transitive operation. Otherwise, it is a non-transitive operation.


//for x=2,y=4,z=8 and operator=+ then 
x+y+z=2+4+8=14
//is equal to
x+y+x=8+4+2=14
//hence it is a transitive operation.
//in case operator1 =+ and operator2=-
x+y-z=2+4-8=-2
//is not equal to
z+y-x=8+2-2=8
//hence it is non transitive operation.

There are the below types of operators available in java

  1. Arithmetic operator
  2. Concatenation operator
  3. Assignment operator
  4. Unary operator
  5. Relational operator
  6. Ternary operator
  7. Conditional operator
  8. Type comparison operator
  9. Bitwise operator
  10. Shift operator
  11. Other Operator
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 24
  • 34
  • 14
  • 12
  •  
  •  
  •  
  • 10
  •  
  •  
    94
    Shares

1 COMMENT

  1. It’s a pity you don’t have a donate button! I’d definitely donate to this brilliant blog! I suppose for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this website with my Facebook group. Chat soon!

LEAVE A REPLY

Please enter your comment!
Please enter your name here