how to create a function inside main in java code example
Example 1: java define main function
public class Program {
public static void main(String[] args){
System.out.println("Hello, World!");
}
}
Example 2: how to write a method inside main in java
public class Main {
static void myMethod() {
System.out.println("I just got executed!");
}
public static void main(String[] args) {
myMethod();
}
}
// Outputs "I just got executed!"