posted 17 years ago
De compilable code is
public class ObjectTest {
public static void main(String[] args) {
byte b = 0;
b = (true) ? (byte)(b + 1) : 100;
System.out.println("Output: " + b);
}
}
The ternary operation assigns a value to a variable depending on the conditional expression
x = (boolean expression) ? value to assign if true : value to assign if false
You have also to cast the value if true (b+1) because of a possible loss of precision error. You could count 128 + 1.
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,