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 Harnessing the Power of Objects Filling the Dispenser

Fill method

Fill is public here. So what does call off the instance method mean?

2 Answers

hi, when u declare a public method u define that any other class in the project could have access to use this method. u gain access to the method by creating an instance of the class that the method is in. for example if the method is on the Car class and u want to get the imaginary method canMove() from that class u will have to create an instance of the class like that: Car car = new Car() and to use the method u simply do: car.canMove();

i hope that helps.

Thanks for clearing the doubt