I want to print a method that is in another class. How do I do that?
Thanks!
The method name I am trying to call is
public void printMenu()...
within a class called FoodMenu
.
I want to print a method that is in another class. How do I do that?
Thanks!
The method name I am trying to call is
public void printMenu()...
within a class called FoodMenu
.
Create an instance of
FoodMenu
and use it to callprintMenu()
FoodMenu
object created bynew
keyword And with help of object you can call its methodf.printMenu();
You will need an object of the class FoodMenu then you can call the method
Do someting like:
if your class FoodMenu is in another package, then import it in the class you are going to define the object.