Assigning a char value to int variable work in Java

时间:2015-07-31 19:55:16

标签: java compilation char int

I came across this assignment while I was practicing

int I = '1'

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

1 个答案:

答案 0 :(得分:-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.

相关问题