0
why the output it's not 30 30 the actual output is: "30 1020"
public class YourClassNameHere { public static void main(String[] args) { int a =10; int b=20; System.out.println(a+b +" "+ a+b); } }
2 Réponses
+ 6
If you want to change the order of how the expression is being evaluated, you have to use parentheses.
Try this:
System.out.println(a+b+" "+(a+b));
+ 3
Implicit string concatenation and implicit conversion is what's going on there, since the expression is evaluated from left to right