Operators in Java

Java Operators : Java Operators is a symbol which is used to perform logical or mathematical manipulations. There are different types of operators available in java such as

Arithmetic Operators
Assignment Operators
Bitwise Operators
Conditional Operator
Logical Operators
Relational Operators

Arithmetic Operators : Java is providing the Arithmetic operators with eight Arithmetic Operators. Arithmetic Operators are similar to basic mathematics that we use for our calculations. Like we can do Addition, Subtraction , Multiplication, Division, Modulo, Increment, Decrement.
Addition ‘+’ operand : Addition operand adds values on either side of the operator

Subtraction ‘-‘ operand : Subtraction operand subtracts right hand side operand from the left hand side operand

Multiplication ‘*’operand : Multiplication operand multiplies values on either side of the operator

Division ‘/’operand : Division operand divides left hand side operand by the right hand side operand

Modulo ‘%’operand : Modulo operand divides left hand side operand by the right hand side operand and which returns remainder

Increment ‘++’operand : Increament operator increases the value of operand by one.

Decrement ‘- -‘operand : Decrement operator decreases the value of operand by one.

Example :

OUTPUT :

Java Arithmetic Operator Example

Assignment Operators : Assignment Operator is used to store the values of the right side variable to left side of the variable.

Assignment ‘=’ operand : Assignment operator assigns the values of the right hand side to left hand side variable.

OUTPUT :

JavaAssignmentOperatorOutput

Logical Operators : Logical operators are used to store the values based on the variables, normally it stores only Boolean values such as true or false.
And Operator ‘&&’in java : Logical And operator returns true if the outcome of both the operands are true

OR Operator ‘||’ in java : Logical OR operator returns true if the outcome of either operands are true

NOT Operator ‘!’in java : Logical Not operator gives the invertion state of the condition

Example :


OUTPUT :

JavaLogicalOperatorOutput

Relational Operator : Relational operators are used to find the comparsion between two or more objects.
Greater than ‘> ’ operand : Greater than operator validates if the value of left hand operand is greater than the value of right hand operand, then condition satisfies which will return true.

Less than ‘<‘ operand : Less than operator checks if the value of left operand is less than the value of right operand. , then condition satisfies which will return true.

Greater than or Equal to ‘>= ’ operand : Greater than or equal to operand checks if the value of left operand is greater than or equal to the value of right operand then condition satisfies which will return true.

Less than or Equal to ‘<=’ operand : Less than or equal to operand checks if the value of left operand is less than or equal to the value of right operand then condition satisfies which will return true.

Equal ‘==’ operand:Equal operand checks if the value of both operands are equal then condition satisfies which will return true.

Not Equal ‘!=’ operand : Not Equal operand checks if the value of two operands are not equal, which will return true if both the values are not equal.

Example :


OUTPUT :

Leave a Comment

Your email address will not be published. Required fields are marked *