Why am I getting “Error: ‘else’ without ‘if'”? [duplicate]

Delete the ; after these lines:

}else if (answer.equals ("Steak"))
...
}else if (answer.equals ("Cake"))

Putting a ; will tell that the else if body is empty.

From this site:

The semicolon tells the ‘if statement’ to do nothing when it is placed
directly after it. In other words: if the statement is true do: ';'
(nothing)

Leave a Comment