Page 1 of 1
About Question com.enthuware.ets.scjp.v6.2.56 :
Posted: Sun Sep 28, 2014 3:05 pm
by piotrkmiotczyk
I'm being linked here from a completely different questions. Mine is a DnD about which operators are legal between which types.
Are the codes not unique?
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
Posted: Sun Sep 28, 2014 7:43 pm
by admin
Should be fixed now.
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
Posted: Sun Oct 26, 2014 1:28 pm
by piotrkmiotczyk
Why does this work:
char c = 'a';
Integer i = 9;
c += i;
I thought adding char to integer causes promotion of char to int (Integer is unboxed to int) and then the result is int type, but IS NOT a constant expression.
The below (with the same declarations) does not work for precisely this reason (and both are char + int assigned to char):
c = 'a'+i;
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
Posted: Sun Oct 26, 2014 7:30 pm
by admin
Because java compiler converts c += i; to c = (char)(c+i); It adds an explicit cast.