Free Data Structures and Algorithms Course









Subscribe below and get all best seller courses for free !!!










OR



Subscribe to all free courses

Operators in Java programming language

Overview of Operator
Java is a very versatile programming language. It is versatile because of many good features. One of the feature it provide is power of Operators. Operators are essential requirement for a good programming language. Java provides a wide set of Operators. These operators help programmer to get the functionality to operate over variables. Generally in Java there are two types of operators:-

1. Unary Operators
They are operators which operate on single operand.
2. Binary Operators
They are operators which operate on two operands.

There are also many classes of Operators some of them are :
1. Arithmetic Operator
2. Comparison Operator
3. Assignment Operator
4. Conditional Operator
5. Bitwise Operator
6. Boolean Operator
Lets have a look to all of the Operators listed above :

Arithmetic Operator
The Java programming language uses arithmetic operators very extensively. Arithmetic operators are used where we have to perform basic mathematical computations. The mathematical computations such as addition, subtraction, division, multiplication etc . Below contains a table which describes Arithmetic Operators, have a look at them carefully.




Comparison Operator
Java provides us with a set of comparison operators which compares value of one variable to value of another variable and based on comparison helps us to build a expression. Generally these sort of operators are been used in the if-else contructs. Generally expression built by these operators are either true or false. It means they will return either true value or false value. This helps in flow of code in if-else constructs. Lets look about them in detail.






Assignment Operator
Java provides us with a set of assignment operators which are normally used to give a value to a variable. After performing mathematical calculations or say conditions from an expressions the returned value is assigned to a variable. Lets look at the below table for its usage :



Conditional Operator
Java provide us with a ternary operator which performs functionality of a if-else constructs. Generally conditional operator uses expression for two variables if condition is true it executes code and if not it executes some other code. Lets have a look how it is use :





Bitwise Operator
Bitwise Operators are quite tricky and complex operators in Java. Generally when a Java application transfer information over a network to a method written in a different programming language we need to do the data conversion. Bitwise operators are used to convert one value to another at bit-level. Lets look at their usage :


Boolean Operator
Generally Boolean Operator are mainly three in number. Lets look into their usage :



Operator Precedence
Generally if a Java expressions contains two or more than two different operators in a statement compiler decides to evaluate which operator first by the concept of operator precedence. Generally Operator Precedence table is followed when evaluating the expression. Let us look at Operator Precedence table:



 
© 2021 Learn Java by Examples Template by Hubberspot