Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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