Advertisements
Advertisements
Question
Rewrite the following program segment using if-else statements instead of the ternary operator.
c = (x >= 'A' && x <= 'Z') ? "Upper Case Letter" : "Lower Case Letter";
Answer in Brief
Solution
String c;
if (x >= 'A' && x <= 'Z')
c = "Upper Case Letter";
else
c = "Lower Case Letter";
shaalaa.com
Is there an error in this question or solution?
Chapter 1.04: Operators in Java - EXERCISES [Page 44]