Let’s take a look on operator = . This is basically assigning a value to our variable. This can also be used to assign object reference. More of this later on my series of java tutorial.

Aside from the equal operator we also have the following:

Java Arithmetic Operators

Operator Description
+ addition and can also be used as string concatenator
* multiplication
/ division
% modulo operator

Java Unary Operators

Operator Description
+ Unary plus operator, indicates positive value however unsign values indicates positive values
Unary minus operator, it negates an expression; mathematically signifies negative numbers
++ Increment operator, increments a value by 1 (example of which is i++)
Decrement operator,decrements a value by 1(example of which is i – -)
! Logical complement operator,inverts the value of a boolean (example is !booleanVar)

This example clearly demonstrates the usage of the java plus operator,java arithmetic operators, and unary operators as well.

and here is the ouput after executing above source code

Notice that we put a simple if condition on the above source code. This is to facilitate demonstration of java unary operator ++. We will be discussing a bit more on the conditional statements later on. Going back on the sample source code, the printing of details gives an overview on how to use +  operator in string manipulation. Usage of primitive data types are also in place like boolean, float, and int.

If you have queries on this part of my java tutorial, don’t hesitate to comment below.

Suggested Reading List