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

why is it that when an int = 0 it can be assigned to different numbers as well?

simple

Make sure to post your comment as an answer so you can get upvoted and stuff! :)

I didn't realise that was a thing but after scrolling down I see it, thank you.

1 Answer

It is a variable, thus meaning the value can vary. So that is why you can assign any number to it. Unlike a constant which cannot change. If I assign a constant int to 0 then I cannot modify that value in any way.