java - else without if when trying to create register system -
java - else without if when trying to create register system -
when trying run next code, produces else without if error.
public void registerstudent(int register) { { if (register >= 100) system.out.println("the maximum number of students allowed on course of study 100."); } else { register = register + 1; system.out.println("you have been registered on course."); } }
you have {
@ origin of method, , forgot {
after if condition.
change
{ if (register >= 100) system.out.println("the maximum number of students allowed on course of study 100."); }
to
if (register >= 100) { system.out.println("the maximum number of students allowed on course of study 100."); }
your current if status enclosed in own block, , separated else clause.
java if-statement
Comments
Post a Comment