What is the output of the following program?
public class dsj {
public static void main(String args[]) {
Number ding = (true || !true) ? new Integer(7) : new Float(16);
System.out.println(ding);
}
}
It is 7.0.
? : operator is not so direct to understand.
Avoid using it, if you are mixing types such as int,float or float,long etc....
Use if...else... control structure.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment