Java if statement Question 6

Question

Identify and correct the errors in each of the following statements:

a)  if (c < 17); 
       System.out.println("c is less than 17");  
b)  if (c => 17) 
       System.out.println("c is equal to or greater than 17");  


a)Error
  Semicolon after the right parenthesis of (c < 17). 
  If not, the output statement will execute regardless of whether the condition in the if is true.

b)Error: The relational operator => is incorrect. Correction: Change => to >=.



PreviousNext

Related