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

Quinn Alexander
Quinn Alexander
401 Points

getting "Are you sure you called `console.printf` in the code block within your if statement body?" and not printing

I feel like i have followed the tutorial and am still not getting a print and getting this error. part 1 was fine but this part isnt working

Conditional.java
int numberOfPeople = 3;
if (4 < numberOfPeople){
  console.printf("your table is ready");
}

1 Answer

Michael Hulet
Michael Hulet
47,912 Points

Your logic here is backwards. Your if condition is sorta backwards, which developers often call "Yoda casing". If you reverse it, the reason why your code doesn't pass may become a bit more clear:

int numberOfPeople = 3;
if (numberOfPeople > 4){
  console.printf("your table is ready");
}

The question asks you to print that string if numberOfPeople is less than 4, but your code only does it if numberOfPeople is greater than 4. If you flip the logic to compare it the other way, your code should pass the challenge. Great job! Also, don't forget to capitalize the Y