+ 1
Why do the integers get concatenated here instead of getting added?
https://code.sololearn.com/cqvYuINFy4Z2/?ref=app Here I used " " before for spacing, but why 6+7 gets printed as 67 instead of 13. Why 6+7 is getting taken as string instead of an integer?
5 Réponses
+ 5
If you want to output a result from expression evaluation, you could wrap it up in parentheses.
System.out.println( " " + ( 6 + 7 ) );
+ 3
Verstappen JVM understand may u want to add numbers as string . If you put brackets to (6+7) then it treat as may be programmer want to add numbers.
+ 3
+ 3
Because the compiler after the quotes interprets the + symbol as a string concatenation character and automatically converts to a string everything that comes after the concatenation character, the result is "" + "6" + "7"