DEV Community

Saravanan B
Saravanan B

Posted on • Updated on

Core Java - Operators and Assignments.

Increment and Decrement:
Pre ++x --x (first increment/decrement) the value and then assign.
post x++ x-- (first assign and the increment/decrement).

Image description

Arithmetic Operators.

Image description

String Concatenation:

Image description

Image description

Relational Operators.

< <= > >= is used to compare primitives except boolean types.

Equality == != can be used with any primitive and also with object to check for object reference.

Image description

Bitwise Operators

& - returns true if both arguments are true
| - returns true if atleast one argument is true.
^ - returns true if both are different.

Image description

bitwise unary operator
~ - it will flip all the numbers ex 10001 will be flipped to 01110.

Short circuit operators

&& - if first value is false then directly it will execute without checking next element.

|| - if first value is true then directly it will execute without checking next element.

It will improve the performance (Faster). Applies to Boolean type only.

Assignment operator

int x = 10; Assign the value of 10 to the x.
int x=y=z= 10;
Compound assignment
int b = 10;
b+= 40; // result b = 50

Ternary operator

testexpression ? value1 : value2

Image description

Top comments (0)