My Java Cert book states this... For unary operators, if the operand is a byte, short or char, it is converted to an in (unless the op is ++ or --) The unary operators are +, -, ++, --, ~ So given this look at the following code byte a = 100; byte b = +a; This will flag an error due to the casting that needs to take place. It should look like this. byte a = 100; byte b = (byte)+a; This this correct?? -Dale
------------------ By failing to prepare, you are preparing to fail. Benjamin Franklin (1706 - 1790) [This message has been edited by Dale DeMott (edited July 12, 2001).]
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Yes, it is correct! As you said yourself, you have to explicitly cast it because Java promotes a literal to int when you use + or - before it. It is similar to the binary +, -, *, / etc... I suppose you've tried it out already... Hidy hooo! /Kaspar