0

what is the problem in "else"

public class elsetest { public static void Main(String[]args) { int b=3; int c=4; if (b<c) { System.out.println(b); } else {System.out.println(c); } } }

26th Mar 2019, 6:59 AM
aminul islam hnc
aminul islam hnc - avatar
4 odpowiedzi
+ 7
You have terminated the if statement with a semi colon, right after the condition. So if statement has already ended, so using else will raise an error as else is only used in an if statement Remove the semi colon after if condition, and you are good to go.
26th Mar 2019, 7:05 AM
Letsintegreat
Letsintegreat - avatar
+ 5
aminul islam hnc check mark my answer if this helped you
26th Mar 2019, 7:31 AM
Letsintegreat
Letsintegreat - avatar
+ 1
Remove semicolon from if (b<c) It will work
26th Mar 2019, 7:04 AM
Saksham Jain
Saksham Jain - avatar
+ 1
thank you for answer
26th Mar 2019, 7:28 AM
aminul islam hnc
aminul islam hnc - avatar