HomeJava

Java for Testers – Addition Operator

Java for Testers – Addition Operator

<<Previous Post                    << Complete Tutorial>>                        Next Post>>

In the previous article, I have explained about different Arithmetic Operators in Java.

In this article, I am going to explain about the first Arithmetic Operator i.e. Addition Operator in Java in detail.

Java for Testers – Addition Operator

Addition Operator (+ sign) adds the values on either side of the plus sign.

Example: 5+6

In the above example, the values 5 and 6 which are on either side of the plus sign are added to result a value 11.

Find the practical demonstration for this example below:

In the above example, the integer values 5 and 6 are added using the Addition Operator ( + ) inside the print statement.

On executing the above program, we will get the following output:

Java for Testers - Arithmetic Operators - example one

In the above program output, the value 11 got printed as it is the resultant of 5+6 inside the print statement.

Addition Operator can be used for the below different purposes:

Note: All the below-listed things that can be performed by the addition operator will be explained in separate upcoming articles.

  1. For adding integer values
  2. For adding floating-point values
  3. For adding decimal values
  4. For adding character values
  5. For concatenating Strings
  6. Addition operator cannot add two boolean values
  7. For adding the variables (i.e. values stored in the variables will be added)
  8. Performing the addition operation on the variables and assigning the result to another variable
  9. For adding integer values with the decimal values
  10. For adding floating-point values with the decimal values
  11. For adding integer values with the character values
  12. For adding integer value with the String values
  13. For adding the values inside the variables with the String values
  14. Used for concatenating String text with the different data type values and values inside the variables
  15. Used in the print statements for concatenating and printing different formats of output

Here concludes this article.

In the next article, I will explain the different ways to declare the variables and assigning the values.

Next Steps:

  • > To learn more about Java, continue to the next post (Click on Next Post link below)
  • > Check complete Java Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below:

Happy Learning 🙂

Arun Motoori (www.QAFox.com)

On a mission to contribute to the Software Testing Community in all possible ways.

<<Previous Post                    << Complete Tutorial>>                        Next Post>>

If you like this article, share it on LinkedIn using the below button:

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *