

{"id":6438,"date":"2018-01-24T12:39:36","date_gmt":"2018-01-24T12:39:36","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=6438"},"modified":"2026-05-07T16:18:49","modified_gmt":"2026-05-07T10:48:49","slug":"java-operators","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-operators\/","title":{"rendered":"Types of Java Operators &#8211; Nourish Your Fundamentals"},"content":{"rendered":"<p>Java Operators are of prime importance in Java. Without operators, we wouldn&#8217;t be able to perform logical and arithmetic calculations in our programs. Thus, having operators is an integral part of a programming language.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78492\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg\" alt=\"Java operators\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF-520x272.jpg 520w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>Java Operators<\/h3>\n<p>Operators in Java are a special type of tokens in Java which, when coupled with entities such as variables or constants or datatypes, result in a specific operation such as addition, multiplication, or even shifting of bits.<\/p>\n<p><strong>Java Operators are mainly of the following types:<\/strong><\/p>\n<ul>\n<li>Arithmetic Operators<\/li>\n<li>Logical Operators<\/li>\n<li>Unary Operators<\/li>\n<li>Assignment Operators<\/li>\n<li>Ternary Operators<\/li>\n<li>Relational Operators<\/li>\n<li>Bitwise Operators<\/li>\n<li>Shift Operators<\/li>\n<li>instanceOf operator<\/li>\n<\/ul>\n<h3>Arithmetic Operators in Java<\/h3>\n<p>Java Arithmetic Operators are used to perform arithmetic operations. There are mainly 5 Arithmetic Operators in Java.<\/p>\n<p>a. Addition(+)<br \/>\nb. Multiplication(*)<br \/>\nc. Subtraction(-)<br \/>\nd. Division(\/)<br \/>\ne. Modulo(%)<\/p>\n<ul>\n<li>The <strong>Addition<\/strong> operator performs addition between two entities on either side of the operator<\/li>\n<li>The <strong>Multiplication<\/strong> operator performs multiplication between two entities on either side of the operator<\/li>\n<li>The<strong> Subtraction<\/strong> operator performs subtraction between two entities on either side of the operator<\/li>\n<li>The<strong> Division<\/strong> operator performs division and returns the quotient value of the division.<\/li>\n<li>The <strong>Modulo<\/strong> operator returns the remainder after dividing the two operands.<\/li>\n<\/ul>\n<p><strong>Java program to illustrate Arithmetic Operators:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\npublic class ArithmeticOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int add,\r\n    sub,\r\n    mul,\r\n    div,\r\n    mod;\r\n    int num1 = 5,\r\n    num2 = 8;\r\n    add = num1 + num2;\r\n    sub = num1 - num2;\r\n    mul = num1 * num2;\r\n    div = num1 \/ num2;\r\n    mod = num2 % num1;\r\n    System.out.println(\"Addition num1+num2 \" + add);\r\n    System.out.println(\"Subtraction num1-num2 \" + sub);\r\n    System.out.println(\"Multiplication num1*num2 \" + mul);\r\n    System.out.println(\"Division num1\/num2 \" + div);\r\n    System.out.println(\"Modulus num2%num1 \" + mod);\r\n  }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Addition num1+num2 13<br \/>\nSubtraction num1-num2 -3<br \/>\nMultiplication num1*num2 40<br \/>\nDivision num1\/num2 0<br \/>\nModulus num2%num1 3<\/div>\n<h3>Logical Operators in Java<\/h3>\n<p>Java Logical Operators, as the name suggests, perform logical operations on the two operands. There are primarily two types of logical operators<\/p>\n<h4>1. Logical AND in Java<\/h4>\n<p>Java Logical AND checks whether the two conditions on either side of the expression is true. If both the expressions are true then it returns false.<\/p>\n<h4>2. Logical OR in Java<\/h4>\n<p>This checks whether either of the two conditions in the expression is true. If any one of the expressions is true, it evaluates to true. However, if none of the conditions are true, then it returns false. One thing to note is that if the first expression is already true, it doesn&#8217;t check the second expression and returns true.<\/p>\n<p><strong>Java program to illustrate Logical Operators in Java:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class LogicalOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    Scanner sc = new Scanner(System. in );\r\n    String uname;\r\n    String course;\r\n    System.out.println(\"Enter the  username\");\r\n    System.out.println(\"Enter the course\");\r\n    uname = sc.next();\r\n    course = sc.next();\r\n    if (uname.equals(\"DataFlair\") &amp;&amp; course.equals(\"Java\")) {\r\n      System.out.println(\"Your course is going on at DataFlair\");\r\n    }\r\n    System.out.println(\"Enter the  username\");\r\n    System.out.println(\"Enter the course\");\r\n    uname = sc.next();\r\n    course = sc.next();\r\n    if (uname.equals(\"DataFlair\") || course.equals(\"Python\")) {\r\n      System.out.println(\"You are either studying at Dataflair or studying python\");\r\n    }\r\n\r\n  }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Enter the username<br \/>\nEnter the course<br \/>\nDataFlair<br \/>\nJava<br \/>\nYour course is going on at DataFlair<br \/>\nEnter the username<br \/>\nEnter the course<br \/>\nDataFlair<br \/>\nRuby<br \/>\nYou are either studying at Dataflair or studying Python<\/div>\n<h3>Unary Operator in Java<\/h3>\n<p>As the name represents, Unary means one. This operator works with only one operand. Below are the following types of unary operators in Java. Let\u2019s learn the operations that will be performed on a single operand. These are the types of Unary operators:<\/p>\n<p><strong>1.<\/strong> Unary plus Operator<br \/>\n<strong>2.<\/strong> Unary minus Operator<br \/>\n<strong>3.<\/strong> Increment Operator<br \/>\n<strong>4.<\/strong> Decrement Operator<br \/>\n<strong>5.<\/strong> Logical Not Operator<\/p>\n<h4>1. Unary plus operator in Java<\/h4>\n<p>The Unary plus operator converts byte, short, and character datatype values into integer values. However, it is redundant since an explicit conversion of a character to an integer can also be done. Characters when converted to integers, return their ASCII value.<\/p>\n<h4>2. Unary Negative Operator in Java<\/h4>\n<p>The unary negative operator works by adding a minus (-) to a value, which means a positive value will become negative, and a negative value will get converted to a positive value.<\/p>\n<h4>3. Increment Operator in Java<\/h4>\n<p>Java increment operator is used for increasing the value of a variable by one. However, there are a few concepts linked with the increment operator.<\/p>\n<ul>\n<li><strong>Pre-increment-<\/strong> In this case, the value of the variable is first increased, and then its used\/ or its result is computed. Example- ++a;<\/li>\n<li><strong>Post-increment-<\/strong> In this case, the value of the variable is first computed and then incremented. Example- a++;<\/li>\n<\/ul>\n<h4>4. Decrement Operator in Java<\/h4>\n<p>Java decrement operator is just the opposite of the increment operator. It decreases the value of the variable by 1.<\/p>\n<ul>\n<li><strong>Pre-decrement<\/strong>&#8211; In this case, the value of the variable is first decreased and then computed. Example- &#8211;a;<\/li>\n<li><strong>Post-decrement<\/strong>&#8211; In this case, the value of the variable is first computed and then decremented by 1. Example- a&#8211;;<\/li>\n<\/ul>\n<h4>5. Logical Not Operator in Java<\/h4>\n<p>Java logical NOT operator flips the value of a Boolean value. It is denoted by a !.<\/p>\n<p><strong>Java program to understand the concept of Unary Operators:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\nclass UnaryOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    res;\r\n    int num3 = 1;\r\n    boolean flag = true;\r\n    char character = 'a';\r\n\r\n    res = +character; \/\/The unary + converts  the character into a integer value\r\n    System.out.println(\"The + operator on character transforms it to ASCII value \" + res);\r\n    num3 = -num3;\r\n    System.out.println(\"The - operator on num1 positive  value \" + num3);\r\n    res = num1++; \/\/First res=num1 then num1++ executed\r\n    System.out.println(\"The res=num1++ returned value of \" + res);\r\n    res = ++num1; \/\/First num1=num1+1 then res=num1\r\n    System.out.println(\"The res=++num1 returned num1 value of \" + res);\r\n    res = num2--; \/\/First res=num2 then num2=num2-1 executed\r\n    System.out.println(\"The res=num2-- returned value of \" + res);\r\n    res = --num2; \/\/First num2=num2-1 then res=num2 executed\r\n    System.out.println(\"The res=--num2 returned num1 value of \" + res);\r\n    \/\/Learning about NOT operator\r\n    System.out.println(\"The NOT operator returns num1 value of \" + !flag);\r\n\r\n  }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The + operator on character transforms it to ASCII value 97<br \/>\nThe &#8211; operator on num1 positive value -1<br \/>\nThe res=num1++ returned value of 10<br \/>\nThe res=++num1 returned num1 value of 12<br \/>\nThe res=num2&#8211; returned value of 5<br \/>\nThe res= &#8211;num2 returned num1 value of 3<br \/>\nThe NOT operator returns num1 value of false<\/div>\n<h3>Assignment Operators in Java<\/h3>\n<p>Java Assignment operators are used to assign values to the variables on the left side of the equals sign. The associativity is from right to left. Meaning that the values on the right are assigned to the values on the left. The right-hand side has to be a constant or a defined variable.<\/p>\n<p><strong>There are the following types of assignment operators:<\/strong><\/p>\n<p><b>1.<\/b> += This returns left=left+right<br \/>\n<strong>2.<\/strong> -= This returns left=left-right<br \/>\n<strong>3.<\/strong> *= This returns left=left*right<br \/>\n<strong>4.<\/strong> \/= This returns left=left\/right<br \/>\n<strong>5.<\/strong> %=This returns left=left%right<\/p>\n<p><strong>An example of a Java assignment operator:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class AssignmentOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    result;\r\n    num1 += 5; \/\/action of num1=num1+ 5\r\n    System.out.println(\"The output of num1+=5 is \" + num1);\r\n    num1 -= 5; \/\/action of num1=num1+ 5\r\n    System.out.println(\"The output of num1-=5 is \" + num1);\r\n    num1 *= 5; \/\/action of num1=num1+ 5\r\n    System.out.println(\"The output of num1*=5 is \" + num1);\r\n    num1 \/= 5; \/\/action of num1=num1+ 5\r\n    System.out.println(\"The output of num1\/=5 is \" + num1);\r\n    num1 %= 5; \/\/action of num1=num1+ 5\r\n    System.out.println(\"The output of num1%=5 is \" + num1);\r\n  }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The output of num1+=5 is 15<br \/>\nThe output of num1-=5 is 10<br \/>\nThe output of num1*=5 is 50<br \/>\nThe output of num1\/=5 is 10<br \/>\nThe output of num1%=5 is 0<\/div>\n<h3>Ternary Operators in Java<\/h3>\n<p>Java ternary operator minimizes and mimics the if-else statement. It consists of a condition followed by a question mark(?). It contains two expressions separated by a colon(:). If the condition evaluates to true, then the first expression is executed, the second expression is executed.<\/p>\n<p><strong>Syntax of the ternary operator in Java:<\/strong><br \/>\n(Condition)?(expression 1):(expression 2);<\/p>\n<p><strong>Java program to evaluate the ternary operator:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class TernaryOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    result;\r\n    String result = (num1 == 10) ? \"num1 has value of 10\": \"num1 does not have value of 10\";\r\n    System.out.println(s); \/\/the value of s is printed\r\n    result = (num2 == 10) ? \"num2 has value of 10\": \"num2 does not have value of 10\";\r\n    System.out.println(result); \/\/the value of result is printed\r\n\r\n  }\r\n\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">num1 has value of 10<br \/>\nnum2 does not have value of 10<\/div>\n<h3>Relational Operators in Java<\/h3>\n<p>Java Relational Operators are used to check the relation between values or variables. The output of relational operators is always a Boolean value. Relational operators are used in if conditions and for loop constraints.<\/p>\n<p><strong>Some relational operators are:<\/strong><\/p>\n<p><strong>a.<\/strong> &lt;(Less than) -returns true if the left entity is less than the right entity<br \/>\n<strong>b.<\/strong> &gt;(Greater than)- returns true if the left entity is greater than the right entity.<br \/>\n<strong>c.<\/strong> &lt;=(Less than or equal to)- returns true if the left entity is smaller than or equal to the right entity.<br \/>\n<strong>d.<\/strong> &gt;=(Greater than or equal to)- returns true if the left variable is greater than or equal to the right entity<br \/>\n<strong>e.<\/strong> ==(equals to) &#8211; returns true if the left and the right entities are equal<br \/>\n<span style=\"margin: 0px;padding: 0px\"><strong>f. <\/strong><\/span>!=(not equals to) &#8211; returns true if the left and right entities are not equal.<\/p>\n<p><strong>Program to implement Java relational operators:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class RelationalOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    e;\r\n    System.out.println(\"The values of num1 and num2 are \" + num1 + \" \" + num2 + \" respectively\");\r\n    System.out.println(\"The value returned when num1&gt;num2 is checked \" + (num1 &gt; num2));\r\n    System.out.println(\"The value returned when num1&lt;num2 is checked \" + (num1 &lt; num2));\r\n    System.out.println(\"The value returned when num1&gt;=num2 is checked \" + (num1 &gt;= num2));\r\n    System.out.println(\"The value returned when num1&lt;=num2 is checked \" + (num1 &lt;= num2));\r\n    System.out.println(\"The value returned when num1==num2 is checked \" + (num1 == num2));\r\n    System.out.println(\"The value returned when num1!=num2 is checked \" + (num1 != num2));\r\n\r\n  }\r\n\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The values of num1 and num2 are 10 5 respectively<br \/>\nThe value returned when num1&gt;num2 is checked true<br \/>\nThe value returned when num1&lt;num2 is checked false<br \/>\nThe value returned when num1&gt;=num2 is checked true<br \/>\nThe value returned when num1&lt;=num2 is checked false<br \/>\nThe value returned when num1==num2 is checked false<br \/>\nThe value returned when num1!=num2 is checked true<\/div>\n<h3>Bitwise Operators in Java<\/h3>\n<p>Java Bitwise operators are generally used to perform operations on bits of data. The individual bits of a number are considered in the calculation and not the entire number itself. There are the following types of bitwise operators:<\/p>\n<p><strong>a.<\/strong> AND(&amp;)<br \/>\n<strong>b.<\/strong> OR(|)<br \/>\n<strong>c.<\/strong> XOR(^)<br \/>\n<strong>d.<\/strong> COMPLEMENT(~)<\/p>\n<p><strong>Java program to understand the Bitwise Operators:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class BitwiseOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    e;\r\n    \/\/num1=10 1010\r\n    \/\/num2=5  0101\r\n\r\n    System.out.println(\"The result after performing num1&amp;num2 \" + (num1 &amp; num2));\r\n    System.out.println(\"The result after performing num1|num2 \" + (num1 | num2));\r\n    System.out.println(\"The result after performing num1^num2 \" + (num1 ^ num2));\r\n    System.out.println(\"The result after performing ~num2 \" + (~num2));\r\n\r\n  }\r\n\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The result after performing num1&amp;num2 0<br \/>\nThe result after performing num1|num2 15<br \/>\nThe result after performing num1^num2 15<br \/>\nThe result after performing ~num2 -6<\/div>\n<h3>Shift Operators in Java<\/h3>\n<p>Java Shift Operators are also a part of bitwise operators. There are the following types of shift operators.<\/p>\n<p><strong>a. Left Shift-<\/strong> Shifts the bits of the number two places to the left and fills the voids with 0\u2019s.<br \/>\n<strong>b. Right Shift-<\/strong> Shifts the bits of the number two places to the right and fills the voids with 0\u2019s. The sign of the number decides the value of the left bit.<br \/>\n<strong>c. Unsigned Right Shift-<\/strong> It is also the same as the right shift; however, it changes the leftmost digit\u2019s value to 0.<\/p>\n<p><strong>Example program in Java to understand shift operators:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class ShiftOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    int num1 = 10,\r\n    num2 = 5,\r\n    e;\r\n    \/\/num1=10 1010\r\n    \/\/num2=5  0101\r\n    System.out.println(\"The result after performing left shift \" + (num1 &lt;&lt; 2));\r\n    System.out.println(\"The result after performing right signed shift \" + (num1 &gt;&gt; 2));\r\n    System.out.println(\"The result after performing right unsigned shift \" + (num1 &gt;&gt;&gt; 2));\r\n\r\n  }\r\n\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The result after performing left shift 40<br \/>\nThe result after performing right signed shift 2<br \/>\nThe result after performing right unsigned shift 2<\/div>\n<h3>instanceOf Operator in Java<\/h3>\n<p>This is a type-check operator. Hence, it checks whether a particular object is an instance of a certain class or not.<br \/>\nIt returns true if the object is a member of the class and false if not.<\/p>\n<p><strong>Java program to test the instanceOf Operator:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">package com.dataflair.operators;\r\nimport java.io. * ;\r\nimport java.util. * ;\r\npublic class InstanceOperator {\r\n  public static void main(String[] args) throws IOException {\r\n    InstanceOperator ob = new InstanceOperator();\r\n    System.out.println(\"Is ob an instance of InstanceOperator class? \" + (ob instanceof InstanceOperator));\r\n\r\n  }\r\n}<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Is ob an instance of InstanceOperator class? true<\/div>\n<h3>Java Operators Precedence and Association<\/h3>\n<p><strong>Precedence<\/strong> of operators defines which operator will be executed first if both operators are mentioned in a single expression.<\/p>\n<p>Example in the expression &#8211; a+b*c. Here, the compiler will read it as (a + (b*c)).<\/p>\n<p><strong>Association<\/strong> is the method by which the compiler decides which expression to evaluate first if the operators are of the same precedence.<\/p>\n<p>For example, the expression a=b=c=100 will be evaluated by the compiler as (a=(b=(c=100)))<\/p>\n<p>The association groups the expressions. However, some operators do not have an order of association. These are called non-associative operators. Associative is of two types, namely left-to-right and right-to-left.<\/p>\n<p><strong>A table with the operator precedences in Java is mentioned below<\/strong>:<\/p>\n<table style=\"height: 1137px\" width=\"744\">\n<tbody>\n<tr>\n<td><b>Level<\/b><\/td>\n<td><b>Operator<\/b><\/td>\n<td><b>Description<\/b><\/td>\n<td><b>Associativity<\/b><\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>=,+=,-=,*=,\/=,%=,&amp;=,^=,|=,&lt;&lt;=,&gt;&gt;=,&gt;&gt;&gt;=<\/td>\n<td>Basic assignment Operators<\/td>\n<td>Right to left<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>?:<\/td>\n<td>ternary<\/td>\n<td>Right to left<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>||<\/td>\n<td>Logical OR<\/td>\n<td>Left to right<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>&amp;&amp;<\/td>\n<td>Logical AND<\/td>\n<td>Left to Right<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>|<\/td>\n<td>bitwise OR<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>^<\/td>\n<td>bitwise XOR<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>&amp;<\/td>\n<td>bitwise AND<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>8<\/td>\n<td>==,!=<\/td>\n<td>equality operator<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>9<\/td>\n<td>&lt;,&lt;=,&gt;,&gt;=,instanceof<\/td>\n<td>relational<\/td>\n<td>not associative<\/td>\n<\/tr>\n<tr>\n<td>10<\/td>\n<td>&lt;&lt;,&gt;&gt;,&gt;&gt;&gt;<\/td>\n<td>shift<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>11<\/td>\n<td>+,-<\/td>\n<td>additive<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>12<\/td>\n<td>*,\/,%<\/td>\n<td>multiplicative<\/td>\n<td>left to right<\/td>\n<\/tr>\n<tr>\n<td>13<\/td>\n<td>(), new<\/td>\n<td>object creation<\/td>\n<td>right to left<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td><span style=\"font-weight: 400\">++,&#8211;,+,-,!,~<\/span><\/td>\n<td>pre-increment,pre- decrement,plus,minus,NOT,bitwise NOT<\/td>\n<td>right to left<\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td><span style=\"font-weight: 400\">++,&#8211;<\/span><\/td>\n<td>unary post increment,unary post decrement<\/td>\n<td>not associative<\/td>\n<\/tr>\n<tr>\n<td>16<\/td>\n<td>[ ], . , ()<\/td>\n<td>access array element,object member,parentheses<\/td>\n<td>left to right<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Summary<\/h3>\n<p>In conclusion, we did learn a lot about Java operators and their types. A good knowledge of operators and when to use them would allow us to develop our programming skills to a great extent. Therefore, it&#8217;s critical to take into account the operators&#8217; potential effects on performance when selecting them.<\/p>\n<p>However, in comparison to other operators, some may be computationally more expensive. In certain situations, repeated division might prove more efficient than the modulo operator (%). By keeping these performance considerations in mind, you can write optimized Java code<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Operators are of prime importance in Java. Without operators, we wouldn&#8217;t be able to perform logical and arithmetic calculations in our programs. Thus, having operators is an integral part of a programming language.&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":78492,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[7625,20701,9287,15084,20702],"class_list":["post-6438","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-java-operators-list","tag-java-operators-with-example","tag-operators-in-java","tag-types-of-operators-in-java","tag-what-are-java-operators"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Types of Java Operators - Nourish Your Fundamentals - DataFlair<\/title>\n<meta name=\"description\" content=\"Java operators are symbols tells the compiler to perform a task. Learn Arithmetic, Unary, Assignment, Relational, Logical, Ternary, Bitwise, Shift operators in Java with Examples\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-operators\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Types of Java Operators - Nourish Your Fundamentals - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Java operators are symbols tells the compiler to perform a task. Learn Arithmetic, Unary, Assignment, Relational, Logical, Ternary, Bitwise, Shift operators in Java with Examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-operators\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-01-24T12:39:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-07T10:48:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Types of Java Operators - Nourish Your Fundamentals - DataFlair","description":"Java operators are symbols tells the compiler to perform a task. Learn Arithmetic, Unary, Assignment, Relational, Logical, Ternary, Bitwise, Shift operators in Java with Examples","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-operators\/","og_locale":"en_US","og_type":"article","og_title":"Types of Java Operators - Nourish Your Fundamentals - DataFlair","og_description":"Java operators are symbols tells the compiler to perform a task. Learn Arithmetic, Unary, Assignment, Relational, Logical, Ternary, Bitwise, Shift operators in Java with Examples","og_url":"https:\/\/data-flair.training\/blogs\/java-operators\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-01-24T12:39:36+00:00","article_modified_time":"2026-05-07T10:48:49+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Types of Java Operators &#8211; Nourish Your Fundamentals","datePublished":"2018-01-24T12:39:36+00:00","dateModified":"2026-05-07T10:48:49+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/"},"wordCount":1767,"commentCount":13,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg","keywords":["Java operators list","Java operators with Example","operators in java","Types of Operators in Java","What are Java Operators"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-operators\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-operators\/","url":"https:\/\/data-flair.training\/blogs\/java-operators\/","name":"Types of Java Operators - Nourish Your Fundamentals - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg","datePublished":"2018-01-24T12:39:36+00:00","dateModified":"2026-05-07T10:48:49+00:00","description":"Java operators are symbols tells the compiler to perform a task. Learn Arithmetic, Unary, Assignment, Relational, Logical, Ternary, Bitwise, Shift operators in Java with Examples","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-operators\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/01\/Operators-in-Java-DF.jpg","width":1200,"height":628,"caption":"Java operators"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-operators\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Types of Java Operators &#8211; Nourish Your Fundamentals"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6438","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=6438"}],"version-history":[{"count":18,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6438\/revisions"}],"predecessor-version":[{"id":148254,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/6438\/revisions\/148254"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/78492"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=6438"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=6438"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=6438"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}