English

Rewrite the following code using single if statement. if(code=='g') System.out.println("GREEN"); else if(code=='G') System.out.println("GREEN"); - Computer Applications

Advertisements
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

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?
2024-2025 (April) Specimen Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×