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) Harnessing the Power of Objects Helper Methods and Conditionals

static for boolean isEmpty

why can't you make a static for the public boolean isEmpty and then just access it without making an instance?

2 Answers

Basic answer: each PezDispenser object you create may be empty or may not be. If isEmpty is static it belongs to the class and can have only one value. But you need the correct value returned for each object.

If you make this method static. You should also have to make the property "mPezCount" static. Else you will get an error. Like Mr.jcorum said making this method static will make the object less real world.