Forums Register Login

What am I doing wrong... This code won't complie, and I don't know why

+Pie Number of slices to send: Send
I was attempting to write and complie the example code found here I keep reciving the following error: "SpotRunTo.java:5: ';' exspected".

I'm guessing that the compiler is telling me that on line 5 it's exspecting a ';' ?

Here's a copy of the code I'm trying to compile:

public class SpotRunTo
{

public static void main( Strings[] args )

if (args.length == 0 )
{
System.out.println( "Spot is now home" );
}
else
{
System.out.println( "Spot is now in " + args[0] );
}
}



What am I missing? I've gone through this many times and I'm lost. I don't see what I'm missing. Thanks in advance for pointing me in the right direction.
+Pie Number of slices to send: Send
 

Originally posted by Jesse Wilson:
... What am I missing? ...


Welcome to JavaRanch!

You are missing 2 braces, and you have an 's' at the end of String.
+Pie Number of slices to send: Send
Thanks a bunch! I was able to finally complie the code! WOO HOOO!!

On a side note: The error message I was reciving at the command line... What was it trying to tell me? I have no idea how I was to decipher that I needed to add braces from the message that the computer spit out.

Thanks again!!
+Pie Number of slices to send: Send
when you're missing braces, things go all kinds of wonky. teh compiler TRIES to figure out what you're doing, but it's usually wrong.

i think that since you didn't have your opening brace in your main method... well... i don't know what it was thinking.

whenever you see that "missing ;" message, if the reported line HAS a semi-colon, look at the few lines above the reported one for anything strange/missing. like a '{' or '}'.
Goodbye moon men. Hello tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 540 times.
Similar Threads
problem with incompatible types comile error
Constructor question
How can you use a loop to track the number of times an option has been chosen?
Values of Hash Map to be 2-dimensional array
unicode escapes
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 22:24:27.