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 trialMichael Wadsworth
394 PointsI'm confused about how a member variable is different from a normal variable.
I understand how variables work, and how to assign values to them, but why is it we have to use a member variable for the PezDispenser.Java field?
1 Answer
Tim Cullen
647 PointsThe difference between a member variable and a so-called normal variable is that a member variable is a member of an object. Which means that paticular variable is only accessible in reference to that instance of the object. Another instance of the same class would have its only instance of that same variable but the two would be located in different memory locations and be treated as completly different variables even though they have the same name.