Main Method Overriding in Java


This tutorial is all about Main Method Overriding in Java.
Many of the folks who are new to Java thinks that compiler will throw error if we are going to override main method in java. But, we can override main method in Java. But we can’t change the method signature.

Here is an example:

  1. class A{
  2. public static void main(String ar[]){
  3. System.out.println("Main A");
  4. }
  5. }
  6. class B{
  7. public static void main(String ar[]){
  8. System.out.println("Main B");
  9. }
  10. }


Readers might read also:



Facebook Comments


Please enter your comment!
Please enter your name here