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 Java Basics Perfecting the Prototype Conditional ints

Jarod "Todd" Foreman
Jarod "Todd" Foreman
2,039 Points

Question of the Day - Java Basics. Add an if statement. Conditional basics.

My code, below, needs a little assistance. I do as well. It has been a while since I have been working in my treehouse studies, so I admit I am a bit dull on the subject. Any guidance would be appreciated. My objective is to add an if statement if the people that are ready is less than 4, and then print "Your table is ready"; from the directions:

Add an if statement to see if there are less than 4 people. Then write out to the console, β€œYour table is ready”

Errors that I receive are: JavaTester.java:126: error: ';' expected If numberOfPeople < 4; ^ JavaTester.java:126: error: illegal start of type If numberOfPeople < 4; ^ JavaTester.java:126: error: illegal start of expression If numberOfPeople < 4; ^ JavaTester.java:126: error: ';' expected If numberOfPeople < 4; ^ JavaTester.java:127: error: illegal start of expression console.printf("Your table is ready"); ^ JavaTester.java:127: error: ';' expected console.printf("Your table is ready"); ^ 6 errors

Any assistance and guidance will be greatly appreciated, thank you all. V/r Todd Foreman

Conditional.java
int numberOfPeople = 3;
If numberOfPeople < 4;
  console.printf("Your table is ready");

2 Answers

Fahad Mutair
Fahad Mutair
10,359 Points

hi Jarod "Todd" Foreman , to make if statement

if (condition) {body}

if (numberOfPeople < 4){
  console.printf("Your table is ready");
}

remember if in lower case

Jarod "Todd" Foreman
Jarod "Todd" Foreman
2,039 Points

You beat me to it - Thanks Fahad. You always have a great answer for me. I appreciate your help. Todd

Jarod "Todd" Foreman
Jarod "Todd" Foreman
2,039 Points

I believe I have answered my own question. The fog in my brain lifted.

Here is what I got, and it worked.

int numberOfPeople = 3;

if (numberOfPeople < 4) {
  console.printf("Your table is ready");
}

Thank you, sorry if I interrupted.

Fahad Mutair
Fahad Mutair
10,359 Points

great lol it happens most the time with me