Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

"Inside your if block, after printing, exit the program" I've been stuck for over an hr and can't figure it out in java?

Inside your if block, after printing, exit the program. But i can't figure out how to write the code in java how to exit. please help?

this is what i have...

int numberOfPeople = 3; if (numberOfPeople < 4); console.printf("Your table is ready."); System.Exit(4);

You need to remove the ; from after if (numberOfPeople < 4);

To get this working try

int numberOfPeople = 3; if (numberOfPeople < 4) console.printf("Your table is ready."); System.Exit(4);

or

int numberOfPeople = 3; if (numberOfPeople < 4) { console.printf("Your table is ready."); } System.Exit(4);

The 2nd approach is preferred.

it says that the System.Exit(4); is wrong... the period between system and exit is the error...

Do you mean

    System.exit(4);

??

yes. it says that's wrong... or a "syntax error."

JavaTester.java:129: error: cannot find symbol System.Exit(3); ^ symbol: method Exit(int) location: variable System of type MockSystem 1 error

note it is exit, with lower case letter e

you did it! thank you! i can't believe my mistake was because it was upper case! thank you for your help!

glad it is working. Please mark as answered.

how do i do that?

I put the old answer in the 'Answer text area' .... You should see "Best answer" check mark there.

1 Answer

note it is exit, with lower case letter e