Lecture 4 Methods in JAVA
Lecture 4 Methods in JAVA
1. Method Declaration
2. Method Definition
3. Method Calling
Creating a Method:
Method Declaration and Definition
public class Main
{
static void myMethod() // Declaration and Definition
{
// code to be executed
}
}
• myMethod() is the name of the method
• static means that the method belongs to the Main class and not an object
of the Main class.
• void means that this method does not have a return value.
Call a Method