If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

JAva help, need to understand

Hello everyone, I desperately need someone to help me figure out why the output, listed on the bottom of post, is giving me a result of 220. I need to understand why this is giving me the result of 220 and if someone can help me fix this to where the result is my initials instead of 220. please help!!!!!!!!

Re: JAva help, need to understand

Due to implicit conversion the chars are converted to their Unicode numbers which are 'D'=68, 'E'=69 and 'S'=83. The sum is 220.

To get the wanted conversion you can give the compiler a hint to nudge it in the right direction, like

System.out.println("" + first + middle + last );

Now the compiler will interpret the + operators involved to mean String concatenation rather than integer addition. So the problem was that + is overloaded for both integers and String and you didn't get the implicit conversions you expected. To be very explicit about it you can do,