im getting a syntax error with my else statement. its not recognizing that i have an if statement preceding if. any suggestions???
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
im getting a syntax error with my else statement. its not recognizing that i have an if statement preceding if. any suggestions???
Sure, post your code and the exact error message. We don't read minds.
Improving the world one idiot at a time!
Are you by any chance getting a message saying
"else without an if" or something like that?
You might wanna check your brackets.
For instance, this would be an issue that might cause an else to not be seen.
if (variable == 5)
System.out.println("Ut oh");
System.out.println("Aw man");
else
System.out.println("What happened?");
doing this will fix that problem:
if (variable == 5)
{
System.out.println("Ut oh");
System.out.println("Aw man");
}
else
System.out.println("What happened?");
The previous one only had the first statement go with the if. The second one was extra and hence caused it to mess up the if and else structure as the it acted like an intermediary statement, hence making it an else without an if.
I can't be more specific as you don't have any code posted.