Main Method Overriding in Java

0
5

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:

Overriding

Methods

 

 

Facebook Comments
(Visited 7 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here