-
Calling Methods
Hi, I have a question that is probably pretty simple to most of you, but I am confused. What is the correct way to make the main method call another method? For instance, if I want the main method to execute method 1 then method 2, how would I go about typing that out?
-
Code:
public static void main(String args[]);
computemethod(); <----- Calls first method
computenextmethod(); <----- Calls second method
public void computemethod()
{
Method 1.
}
public void computenextmethod()
{
Method 2.
}
hope that helps
-
You have to think about parameters and return values of a method as well. And also you can't referenced non-static method from a static method also.
-
In order to reference non-static methods , you will have to create object of the class in main and call those methods.