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?
About Question com.enthuware.ets.scjp.v6.2.56 :
Moderator: admin
-
- Posts: 27
- Joined: Mon Sep 22, 2014 1:30 pm
- Contact:
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
Should be fixed now.
If you like our products and services, please help us by posting your review here.
-
- Posts: 27
- Joined: Mon Sep 22, 2014 1:30 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
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;
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;
-
- Site Admin
- Posts: 10036
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.56 :
Because java compiler converts c += i; to c = (char)(c+i); It adds an explicit cast.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 52 guests