0

I came across this assignment while I was practicing

int I = '1'

I didn't understand how does it compile, can some please explain?

doubleH90
  • 163
  • 4
  • 17

1 Answers1

-2

First of all char is numeric type so it contains the code of letter (UTF-16 code units).

Then we have conversion rules for various types. And this is widening primitive conversion.

Alex Silkovsky
  • 541
  • 5
  • 18
  • I believe this is actually correct. But further explanation needed. (I was not a down-voter). – tier1 Jul 31 '15 at 20:49