Stack Exchange
Stack Overflow
Questions
Tags
Users
About
Stack Overflow
Public
Questions
Tags
Users
About
Output of System.out.println( m[1]+` ´+m[ 2])
Asked
Oct 27 '15 at 21:24
Active
Oct 27 '15 at 21:25
Viewed
79 times
0
int m[ ]= {2,4,6,8} System.out.println( m[1]+' '+m[2])
Why is the output 42 in this case?
java
arrays
char
edited Oct 27 '15 at 21:25
aioobe
413,195
112
811
826
asked Oct 27 '15 at 21:24
old_monk
63
9
Because `' '` is a char (which is treated as a number). Try using `" "` instead of `' '`.
–
aioobe
Oct 27 '15 at 21:26
Cause your adding (int) 4 to a (char)6 = 4 + 38 = 42
–
Hans
Oct 27 '15 at 21:29
Thank you. That was helpful.
–
old_monk
Oct 27 '15 at 21:34
0 Answers
0