Hi,
The example above performs the following
107|35 (Here 107 is the ascii of character 'k')
Even though you dont need to know the ascii values , I think
you should know that in any arithmetic expression involving byte/short/char, they are always widened to an int.
For example:
byte b = 10;
short s = 12;
char c = 'r';
b + s + c = ?
int i = b + s + c;
Another example:
byte b = 3, c = 4;
byte d = b + c; //error since b + c will be widened to an int
So the above error can be fixed in 2 ways
1. byte d = (byte) (b + c);
2. int d = b + c;
I hope this helps.
[ November 21, 2003: Message edited by: Cathy Song ]