# Java programming - illegal start of expression



## bigk

Hey every one, 

I'm new to Java programming and I've been makeing this text adventure game. But for some reason I got this "illegal start of expression" error. Can any one help me out?  The error is on the 5th line. (private void doGo line) Also I just copy a 3-5 lines above and below the paragrph of where the problem is. So you get a idea of what around the problem too.

Here's a small part of my code: 

------------------------------------------------------

} else 
{
io.showoutput("nothing happened.");
}
private void doGo (String direction) 
{
if(direction == null) }{
// if there is no second word, we don't know where to go...
System.out.println("Go where?");
return;
}

// Try to leave current room.
Room nextRoom = currentRoom.getExit(direction);

if (nextRoom == null)
io.showOutput("I can't go that way.");
else {
currentRoom = nextRoom;
io.clear();
updateOutput();
}
}
private void updateOutput()
{
io.showOutput("room: " + currentRoom);
io.showOutput(currentRoom.getDescription());

------------------------------------------------------

Also if i come across any more errors could I private message any one? 

Thank you for reading, MERRY CHRISTMAS!  

Bigk


----------



## Chicon

Hi bigk,

A *}* is missing before the 5th line.


----------



## bigk

Thank you for replying. I'm haveing some trouble finding where to put the }.

bigk


----------



## Chicon

Code:


[SIZE=4]
 } else
{
io.showoutput("nothing happened.");
}
[B]}[/B]  [COLOR=Red]<----- here[/COLOR]
private void doGo (String direction)
{
if(direction == null) }{
[/SIZE]


----------



## bigk

The code said:


> ------------------------------------------------------
> 
> } else
> {
> io.showoutput("nothing happened.");
> }
> private void doGo (String direction)
> {
> if(direction == null) }{ <----------- THIS ONE.
> // if there is no second word, we don't know where to go...
> System.out.println("Go where?");
> return;
> }
> 
> // Try to leave current room.
> Room nextRoom = currentRoom.getExit(direction);
> 
> if (nextRoom == null)
> io.showOutput("I can't go that way.");
> else {
> currentRoom = nextRoom;
> io.clear();
> updateOutput();
> }
> }
> private void updateOutput()
> {
> io.showOutput("room: " + currentRoom);
> io.showOutput(currentRoom.getDescription());
> 
> ------------------------------------------------------


Now it saying it this one that has the "illegal start of expression". (It just went two lines down.)

I've been able to deal with the other problems with I have come across so far when it comes to debugging. But I'm lost on the "illegal start of expression" problem. It you don't want to help any furthur I understand. I just don't want it to become a chain of problems and haveing you helping me through each and every one of them.

Thank you so far!

Bigk


----------



## Chicon

Sorry, I didn't check the remaining code.

* if(direction == null) }{ * is incorrect, there is a } too much.

It must be : * if(direction == null) { *

May I know the development tool you are using ?


----------



## bigk

Chicon said:


> May I know the development tool you are using ?


Blue J

bigk


----------



## bigk

YES! The "illegal start of expression" is now gone! (for now) Thanks to you! I've come across other problems but I think I can handle them plus I don't want to drag this out any longer. Also could you or some one else explain to me in laymans terms what the "illegal start of expression" means? 

I hope you have a good day, 

Bigk


----------



## Chicon

I never used Blue J. I'm using either Eclipse or Borland Jbuilder. 

The "illegal start of expression" generally occurs because there's a mistake just prior to the expression.

:up:


----------



## kev269

i personally like JCreator, not many people seem to use it.


----------



## Chicon

kev269 said:


> i personally like JCreator, not many people seem to use it.


Nice tool ! I just had a look on it. :up:


----------

