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 Methods and Constants

Joshua Villaruz
Joshua Villaruz
2,842 Points

Why the method is void load? not int load?

i wish my question is valid hehehe i'm confused. the variable that you will store in load is an integer right?

1 Answer

Jeremy Faith
PLUS
Jeremy Faith
Courses Plus Student 56,696 Points

Although the method is setting variable mPezCount with a constant MAX_PEZ (which are integers), the method does not return a value. So in the method declaration you need to use void which indicates there will be no return value. Had you wanted to return mPezCount then you would have used int in the method declaration.

Joshua you should probably mark this as best answer as it would be nice :) i upvoted and this is true for other programming languages that are void of a return type