Languages
[Edit]
EN

Java - operators

0 points
Created by:
illona
526

In this article, we would like to show you operators that are used to perform operations on variables and values in Java.

OperatorNameDescriptionExample
+additionadds together two valuesa + b
-subtractionsubtracts the second value from the first onea - b
*multiplicationmultiplies two valuesa * b
/divisiondivides the first value by the second onea / b
%modulusreturns the division remaindera % b
++incrementincreases the value of a variable by 1a++
--decrementdecreases the value of a variable by 1a--

 

Practical examples

Edit

1. + operator

Edit

In this example, we use + operator to sum two values.

Output:

2. - operator

Edit

In this example, we use - operator to subtract two values.

Output:

3. * operator

Edit

In this example, we use * operator to multiply two values.

Output:

4. / operator

Edit

In this example, we use / operator to divide the first value by the second one.

Output:

5. % operator

Edit

In this example, we use % operator to get the division remainder.

Output:

6. ++ operator

Edit

In this example, we use ++ operator to increment the result value.

Output:

7. -- operator

Edit

In this example, we use -- operator to decrement the result value.

Output:

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Java - arithmetic operations

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join