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 Objects (Retired) Meet Objects Refresher

int weightCraig = 160; int weightMonty = 130; if (weightMonty weightCraig) {

< less sign will come here

2 Answers

andren
andren
28,558 Points

The question states that:

I would like to see if Monty the office Great Dane weighs more than me.

To do that you have to use the ">" greater than sign, if you use the "<" less than sign then you are checking if the dog weighs less than Craig, which is the opposite of what the question is asking for.

No still confused Help me compare the weights below. I would like to see if Monty the office Great Dane weighs more than me int weightCraig = 160; int weightMonty = 130; if (weightMonty weightCraig) { console.printf("Whoa that's a huge dog!"); } So Monty is 130 less then Craig

Question is (weightMonty < weightCraig)

andren
andren
28,558 Points

Monty weighs less than Craig, that is correct. But it is also completely irrelevant to the question.

The question asks you to write the code such that it checks to see if Monty's weight is greater than Craig's weight, if you use the < sign in the if statement then the code will check if Monty weighs less than Craig, which as I mentioned above is the opposite of what the question asks you to do.

For this question you can essentially completely ignore the values that are actually assigned to the weightMonty and weightCraig variables, the if statement is the only thing the question actually is concerned about, and how that should be written does not change based on the values assigned to those variables.

Got it. I read the question again. its lil tricky.