java main method is hidden

MainMethod6

1 package main;
2 
3 public class MainMethod6 extends SuperClass2{
4     public static void main(String[]args) {
5         System.out.println("main() in MainMethod6");
6     }
7 
8 }

SuperClass2

1 package main;
2 
3 public class SuperClass2 {
4     public static void main(String[]args) {
5         System.out.println("main() in SuperClass2");
6         
7     }
8 
9 }

operation result

 

In the run results show MainMethod only call their main method, indicating the subclass hides the main method of the parent class 

Guess you like

Origin www.cnblogs.com/YanJieMao/p/11482759.html