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 trialhamdan hassan
Courses Plus Student 640 PointsCan someone answer this
How can we return MAX_MISSES - letter.length() MAX_MISSES is a constant and therefore cannot be changed
1 Answer
andren
28,558 PointsYou aren't changing the value of MAX_MISSES
you are just using it in an equation. The -
operator tells Java to subtract two numbers and generate a new number from that calculation.
So this code:
return MAX_MISSES - letter.length();
Tells Java to take the value of MAX_MISSES
and subtract the returned value of letter.length()
and then return that new calculated value. It does not tell it to change either of the values involved in the calculation.
If you wanted to change the value of a variable while subtracting then you would use the -=
operator instead.