Jump to content

New Java user, Else without If error

- - - - -

  • Please log in to reply
1 reply to this topic

#1
blady20

blady20

    Newbie

  • Members
  • Pip
  • 1 posts
Hey guys. Im new to java, and when recompiling this code I get Else without If error. This isn't the whole class but this is where the errors are.

Quote

public void sendChatMessage(String s)
{
if(s.equals("@spawn"));
{
respawnPlayer();
}
else if(s.equals("@packet"));
{
sendQueue.addToSendQueue(new Packet3Chat("test"));
}
else if(s.equals("COMMAND"));
{
//statements
}
else if(s.equals("COMMAND"));
{
//statements
}
else if(s.equals("COMMAND"));
{
//statements
}
else if(s.equals("COMMAND"));
{
//statements
}
else if(s.equals("COMMAND"));
{
//statements
}
else
{
sendQueue.addToSendQueue(new Packet3Chat(s));
}
}


the "COMMAND" and //statement are just space holders for future modifications

Thanks in advance. =D

#2
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
Lose the semicolons after if statements.


if(s.equals("@spawn"));




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users