I am Confused as to why this returns 1;
(char)('0' + 11) = ;
why?
Full code below where ending = 1;
char[] ending;
char a = (char)('0' + 11/10);
ending = new char[]{a, (char)('0' + 11)};
System.out.println(ending);
I am Confused as to why this returns 1;
(char)('0' + 11) = ;
why?
Full code below where ending = 1;
char[] ending;
char a = (char)('0' + 11/10);
ending = new char[]{a, (char)('0' + 11)};
System.out.println(ending);
'0'
is 48.';'
.You can check char
values in integer value in any ASCII Character Set in internet.
In Java, char
can be use as a int
, short
, byte
, long
with values between 0 and 65535 without any casting.
A better explanation is found in: Java char is also an int?
You are assigning '1' to variable a. '0' + 11/10 => '0' + 1 You are assigning a two letter string to endings. Le first letter is a ('1') the second is a semi colon. ('0' + 11).