As you can see Will the following code compile ? 1. byte b=2; 2. byte b1=3; 3. b*=b1; The Answer is Yes But Will the following code compile ? 1. byte b=2; 2. byte b1=3; 3. b=b*b1; The Answer is No , explicit cast from int to byte needed Why? b*=b1; does not equal to b=b*b1 ?
irisly
Greenhorn
Joined: Jul 26, 2001
Posts: 2
posted
0
I want to know how to explain it. Who can tell us? thanks!
Hi Chan, byte b,b1=1; b *= b1; Here b *= b1 means b = (byte)b*b1; implicit casting is happening here (in ur case-1), which is not happening in the second case. ------------------ azaman [This message has been edited by Ashik uzzaman (edited August 20, 2001).]
Ashik Uzzaman Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Ragu Sivaraman
Ranch Hand
Joined: Jul 20, 2001
Posts: 464
posted
0
Originally posted by Jeremy Chan: As you can see Will the following code compile ? 1. byte b=2; 2. byte b1=3; 3. b*=b1; The Answer is Yes But Will the following code compile ? 1. byte b=2; 2. byte b1=3; 3. b=b*b1; The Answer is No , explicit cast from int to byte needed Why? b*=b1; does not equal to b=b*b1 ?
b*=b1; It is Arithmetic Extended Assignment Operation Implicit Casting is OK b=b*b1; Binary Operation with simple assignment Implicit casting not applicable
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.