I have an assignment for school, and one of the tasks is to explain a lot of tiny calculations and explaining why java gives you the output it gives you..
and one of the calculations is:
1 + '2' + 3
which for me gives a lexical error, as the teacher used the wrong "apostrophes" for my system, but I've talked to other fellow students and they told me they got an actual output, so I started reading about it, and found out that it is supposed to signify a char variable, and I also found out about the system specific types, so I changed the signs to work for my system, and now I get the answer 54..
and I cannot see the logic in it, and I've tried to google adding/calculating/math with char variables, and have found nothing that explains it well..
So I turn to you, the people of coding, that I one day might be a part of to help me understand the logic of this..
this started out as a homework assignment that I probably could have gotten through by just answering that it gives a lexical error because my compiler doesn't understand the symbol, but now it's peaked my curiosity, and I really want to know how java manages to get this answer..
thank you for any help on the matter! :)
I can see that I couldn't make a 'homework' tag, so I hope it's okay that I put it here :)
1is anintand wider than acharso you should expect anintresult.