examples of main method java
Example 1: java main
class myClass {
public static void main(String[] args) {
// code
}
}
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!"