There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen boot bsod computer connection crash css dell drive driver drivers email error ethernet excel explorer firefox firefox 3 game hard drive internet internet explorer itunes laptop lcd linux malware monitor network networking outlook outlook 2003 outlook express printer problem problems ram router slow sound sprtcmd.exe startup trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Java programming - illegal start of expression


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
bigk's Avatar
Computer Specs
Senior Member with 377 posts.
 
Join Date: Jul 2005
Location: U.S.A
Experience: Advanced
23-Dec-2005, 03:22 AM #1
Java programming - illegal start of expression
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
__________________
I enjoy getting private messages from people. Please feel free to private message me at any time.
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
23-Dec-2005, 03:27 AM #2
Hi bigk,

A } is missing before the 5th line.
bigk's Avatar
Computer Specs
Senior Member with 377 posts.
 
Join Date: Jul 2005
Location: U.S.A
Experience: Advanced
23-Dec-2005, 04:06 AM #3
Thank you for replying. I'm haveing some trouble finding where to put the }.

bigk
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
23-Dec-2005, 04:13 AM #4
Code:

 } else
{
io.showoutput("nothing happened.");
}
} <----- here
private void doGo (String direction)
{
if(direction == null) }{
bigk's Avatar
Computer Specs
Senior Member with 377 posts.
 
Join Date: Jul 2005
Location: U.S.A
Experience: Advanced
23-Dec-2005, 04:24 AM #5
Quote:
Originally Posted by The code

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

} 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
__________________
I enjoy getting private messages from people. Please feel free to private message me at any time.
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
23-Dec-2005, 04:36 AM #6
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's Avatar
Computer Specs
Senior Member with 377 posts.
 
Join Date: Jul 2005
Location: U.S.A
Experience: Advanced
23-Dec-2005, 04:38 AM #7
Quote:
Originally Posted by Chicon
May I know the development tool you are using ?
Blue J

bigk

Last edited by bigk : 23-Dec-2005 04:43 AM.
bigk's Avatar
Computer Specs
Senior Member with 377 posts.
 
Join Date: Jul 2005
Location: U.S.A
Experience: Advanced
23-Dec-2005, 04:43 AM #8
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
__________________
I enjoy getting private messages from people. Please feel free to private message me at any time.
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
23-Dec-2005, 04:51 AM #9
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.

kev269's Avatar
Member with 69 posts.
 
Join Date: Nov 2004
Experience: Advanced
23-Dec-2005, 01:51 PM #10
i personally like JCreator, not many people seem to use it.
Chicon's Avatar
Computer Specs
Distinguished Member with 6,677 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
23-Dec-2005, 02:28 PM #11
Quote:
Originally Posted by kev269
i personally like JCreator, not many people seem to use it.
Nice tool ! I just had a look on it.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 07:08 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.