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
Michael Hamilton
562 Points"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);
Michael Hamilton
562 Pointsit says that the System.Exit(4); is wrong... the period between system and exit is the error...
markmneimneh
14,133 PointsDo you mean
System.exit(4);
??
Michael Hamilton
562 Pointsyes. 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
markmneimneh
14,133 Pointsnote it is exit, with lower case letter e
Michael Hamilton
562 Pointsyou did it! thank you! i can't believe my mistake was because it was upper case! thank you for your help!
markmneimneh
14,133 Pointsglad it is working. Please mark as answered.
Michael Hamilton
562 Pointshow do i do that?
markmneimneh
14,133 PointsI put the old answer in the 'Answer text area' .... You should see "Best answer" check mark there.
1 Answer
markmneimneh
14,133 Pointsnote it is exit, with lower case letter e
markmneimneh
14,133 Pointsmarkmneimneh
14,133 PointsYou 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.