**Core JAVA**

Java Runtime Environment (JRE)

Java Virtual Machine (JVM)

Java overview

Java basics

Java Objects and classes

Java Constructors

Java basic datatypes

Java variable types

Java modifiers/Access Modifiers In Java

Java Basic Operators

Java Loops and Controls

Java conditions

Java numbers and characters

**Java strings**

Java arrays

Java date time

Java methods

Java file and IO operations

Java exceptions

Inner class

**Java OOPs Concepts**

Java Inheritance

Java Polymorphism

Java Abstraction

Java Encapsulation

Java Interface

Cohesion and Coupling

Association, Aggregation and Composition

**Java Collections**

Java ArrayList

Java LinkedList

Set and HashSet

LinkedHashSet and TreeSet

Queue and PriorityQueue

Deque and PriorityQueue

Java Map Interface

Java HashMap

Internal Working Of Java HashMap

**Java Mutithread**

Methods of Thread In Java

Join , run & Start Method in Threads

Difference b/w start & run Methods in Threads

Java Concurrency Package & its Features

CountDownLatch, CyclicBarrier, Semaphore and Mutex in Thread

__Java Operators and Types__

__Java Operators and Types__

**Java **operators covers types and details of various mathematical and logical operations, we use in java programming.

Simple example can be addition (+), subtraction(-) and multiplication(*) (mathematical operators) which we learned in mathematics same is available in java for doing calculations.

**Below is list of different java basic operators c****ategories:**

- Arithmetic operators in java
- Relational operators in java
- Logical operators in java
- Bitwise operators in java
- Type and conditional operator

__Arithmetic Java Operators__

__Arithmetic Java Operators__

Arithmetic operations are simple mathematical operations between two numbers.

In below table we are seeing example with int primitive variable type, we can use these operators with float, double etc. as well.

Operator symbol and name | Details | Java Examples |
---|---|---|

+ (Addition operator) | Used to add two numeric variables. | int a=2, b=20; int c = a + b; //if we print value of c, it //will be 22 |

– (Subtraction) | Used to subtract two numeric variables. | int a=2, b=20; int c = b-a; //if we print value of c, it //will be 18 |

* (Multiplication) | Used to multiply two variables. | int a=2, b=20; int c = b*a; //if we print value of c, it //will be 40 |

/ (Division) | Divides two variable. | int a=2, b=20; int c = b/a; //if we print value of c, it //will be 10 |

% (Modulus) | Divides two variables and returns remainder. | int a=2, b=21; int c = b%a; //if we print value of c, it //will be 1 |

++ (Increment) | Increases variable’s value. | int a=2; a++; //if we print value of c, it //will be 3 |

– -(Decrement) | Decreases variable’s value. | int a=2; a–; //if we print value of c, it //will be 1 |

__Relational Java Operators__

__Relational Java Operators__

Relational operators are used to compare two variables and check which one is less or greater or equal.

Operator Symbol and Name | Details | Java Examples |
---|---|---|

== (equal equal) | Used to compare two variables equality, returns true or false. | int a=20, b=20; if(a==b) //if evaluate, if condition, it will return true. |

!= (not equal) | Used to compare if two variables values are not equal. | int a=2, b=20; if(a!=b) //if evaluate, if condition, it will return true. |

>(Greater than operator) | Used to check if left side variable is greater than right side. | int a=2, b=20; if(b>a) //if evaluate, if condition, it will return true. |

<(Less than) | Used to check if left side variable is less then right side. | int a=2, b=20; if(a
//if evaluate, if condition, it will return true. |

>= (Greater than equal) | Used to check if left side variable is greater then or equal to right side variable. | int a=2, b=20; if(a>=b) //if evaluate, if condition, it will return false. |

<=(Less than equal) | Used to check if left side variable is less than or equal to right side variable. | int a=2, b=20; if(a<=b) //if evaluate, if condition, it will return true. |

__Logical Java Operators__

__Logical Java Operators__

Logical operators are used for some logical calculation between two variables.

**See below table to understand them:**

Operator Symbol and Name | Details | Java Examples |
---|---|---|

&&(AND operator) | Used to perform logical AND operation between left and right side of expressions. | if(20==20 && 30==30) //if we carefully see this expression, we will get true in this if condition because left side and right side of && are true |

|| (OR operator) | Used to perform logical OR operation between left and right side of expressions. | if(20==20 || 20==30) //if we carefully see this expression, we will get true , even if 2nd condition is false. |

‘! (NOT operator) | Used to perform logical not operation. | if(20!=30) //if we carefully see this expression, we will get true as 20 is not equal to 30 |

__Bitwise Operators__

__Bitwise Operators__

Bitwise operators are used to do operations on binary numbers (0/1), so if you apply a bitwise operation on two int, it will actually convert these two int numbers into binary number internally and then will do bitwise operation.

**For example int 1 (0001 in binary) and int 2 (0010 in binary), let’s see some bitwise operations:**

int a=1; //(0001)

int b=2; //(0010)

a&b = 0000

Operator Symbol and Name | Details | Java Examples |
---|---|---|

&(bitwise and operator) | It does bitwise and operation on binary value of number. | Int a=1, b=2; Int c = a&b |

| (or operator) | It does bitwise or operation on binary value of number. | |

^ (XOR) | It does bitwise xor operation on binary value of number. | |

~ (bitwise compliment) | It is ones complement, flips the bits from 1 to 0 and 0 to 1. | |

<< (left shift) | The left side value is moved to left by number of times specified in right side value. | |

>>(right shift) | The left side value is moved to right by number of times specified in right side value. | |

>>>(zero fill right shift) | The left side value is moved right by number of bits specified by left one and shifted values are flipped. |

__Assignment Operators__

__Assignment Operators__

Operator Symbol and Name | Details | Java Examples |
---|---|---|

!ERROR! undefined variable ‘equals’ | Used to assign left variable value of right one. | Int a=1, b=2; |

+= | It is used to add on left variable with right and assign to left. | |

-= | It is used to substract on left variable with right and assign to left. | |

*= | It is used to multiply on right variable with right and assign to left. | |

/= | It is used to divide on left variable with right and assign to left. | |

%= | It returns modulus of left and right data and assigned to left. | |

<<= | Left shift AND operator. | |

>>= | Right shift and assignment operator. | |

&= | Bitwise AND and assignment operator. | |

!= | Bitwise OR and assignment operator. |

__Type And Conditional Operator__

__Type And Conditional Operator__

**· instanceof –** Checks if left side object is instance of right side class, returns true or false.**Syntax:** instanceof

**· ?: (Conditional) –** It is used to check a condition and return in if else way some value.**Syntax :** (Condition/Expression)? :

Example: String message = (20>10)? “Yes” : “No”

__Next Article To Read__

__Next Article To Read__

Now you have great understanding of various operators in java, next you can read our article where we will discuss different java loops: