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

.class error on <

Hi there, my if statement condition (int < 4) seems to be producing a .class error on the <. Any idea where this - probably very basic - error crept in? Thanks in advance, Dominic

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

3 Answers

Hi Dominic,

You've also put a semi-colon after the if condition; that needs to be removed too:

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

With that semi-colon in there, the printf will always be executed as it is not part of the if conditional.

int numberOfPeople = 3;
if(numberOfPeople == 4); {
  console.printf("Always prints");
}

The compiler in the code challenge ignores this, however! The following with clear task 2:

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

And that's not correct. :worried:

Steve.

In your if statement you should be checking the variable name and not the variable data type: numberOfPeople instead of int.

changed from comment to answer

thanks mate

G谩bor T贸th
G谩bor T贸th
11,958 Points

In your if statement, you should check if numberOfPeople is bigger than 4 and not the data type, int. Hope that helps.

cheers thanks mate