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