all types of methods and calling them code example
Example 1: calling method in java
public class MyClass {
void myMethod() {
System.out.println("You have called me! My name is: myMethod!");
}
public static void main(String[] args) {
new MyClass().myMethod();
}
}
Example 2: java method
public class Main {
public static void main(String args[]) {
SayHi();
int sum = AddNums(5, 6);
System.out.println(sum);
}
public static void SayHi() {
System.out.println("Hi!");
}
public static int AddNums(int a, int b) {
return a + b;
}