<<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:
public class Demo { public static void main(String[] args) { System.out.println(5+6); } }
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:
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.
- For adding integer values
- For adding floating-point values
- For adding decimal values
- For adding character values
- For concatenating Strings
- Addition operator cannot add two boolean values
- For adding the variables (i.e. values stored in the variables will be added)
- Performing the addition operation on the variables and assigning the result to another variable
- For adding integer values with the decimal values
- For adding floating-point values with the decimal values
- For adding integer values with the character values
- For adding integer value with the String values
- For adding the values inside the variables with the String values
- Used for concatenating String text with the different data type values and values inside the variables
- 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>>