Caution! In Java, the ‘+’ operator serves dual purposes: for both addition and concatenation. It performs addition when used with numerical values and concatenation when used with strings. |
When you add two numbers in Java, the result will be another number.
|
Adding two strings results in their concatenation.
|
Adding a number to a string results in string concatenation.
|