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 trialDominic Widmer
3,040 Points.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
int numberOfPeople = 3;
if (int < 4); {
console.printf("Your table is ready");
}
3 Answers
Steve Hunter
57,712 PointsHi 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.
Steve.
Pedro Cabral
Full Stack JavaScript Techdegree Student 23,916 PointsIn your if statement you should be checking the variable name and not the variable data type: numberOfPeople instead of int.
Jason Anello
Courses Plus Student 94,610 Pointschanged from comment to answer
Dominic Widmer
3,040 Pointsthanks mate
G谩bor T贸th
11,958 PointsIn your if statement, you should check if numberOfPeople is bigger than 4 and not the data type, int. Hope that helps.
Dominic Widmer
3,040 Pointscheers thanks mate