Rewrite the following code using single if statement. if(code=='g') System.out.println("GREEN"); else if(code=='G') System.out.println("GREEN");
Advertisements
Question
Rewrite the following code using single if statement.
if(code=='g')
System.out.println("GREEN");
else if(code=='G')
System.out.println("GREEN");One Line Answer
Advertisements
Solution
if(code=='g' || code=='G')
System.out.println("GREEN");shaalaa.com
Introduction of Conditional Statements in Java
Is there an error in this question or solution?
