+ 1
Outputs of this code?
3 ответов
+ 24
+ works as concatenation (joining) operator. So
2*2+2/2
= 4+1
= 41
If you want 5 as output, then use parentheses as follows :
(2*2+2/2)
+ 9
System.out.println("4+4/2*3="+2*2+2/2);
outputs
4+4/2*3=41
because first a string is printed, so the results of the calculations 2*2 (=4) and 2/2 (=1) are concatenated to the string 41.