Forums Register Login

Arithmetic Compound Assignment Operators..

+Pie Number of slices to send: Send
Why i get output for the below program?

---------- Run ----------
Hello World!
Normal Termination
Output completed (0 sec consumed).



+Pie Number of slices to send: Send
To the Batmobile!

Oh no, that should be Java Language Specification, or anywhere where you can read that the compound operators can return their original type rather than going to int.

It is quite complicated; they can create an int and then return it to their original type, so your example will compile and run happily, but you can get some unexpected results if you use types "narrower" than int (short, byte, char). It is described lot better in the Java Language Specification page I showed you. "Complete abruptly" means to suffer an exception at runtime.
Just the other day, I was thinking ... about this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1076 times.
Similar Threads
about ?: operator
format method
SCJP 5: Mock questions
Matching words except those in tags with regex
problem related to floats
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:43:13.