PB.MAIN
Use the method name 'main' only for the entry point method
Description
This rule checks whether the method name `main' is used for something other than the entry point method.
Because the method name `main' has a special meaning in Java, you can avoid confusion by not using it for purposes other than defining 'public static void main(java.lang.String[])'.
Example
package PB;
public class AMOP {
public static void main(String[] args) {
System.out.println("This is main method");
}
public static void main() { //violation
System.out.println("This is another main method");
}
}
Repair
package PB;
public class AMOP {
public static void main(String[] args) {
System.out.println("This is main method");
}
public static void other_main() {
System.out.println("This is another main method");
}
}
|