What is the use of main method in abstract class?

后端 未结 4 835
攒了一身酷
攒了一身酷 2021-02-05 10:00

I know that we can write main method in abstract class, but what we can achieve from it ?

 public abstract class Sample
 {
         public static void main(Strin         


        
4条回答
  •  清歌不尽
    2021-02-05 10:19

    As Zeeshan already said, since the main method is static, it does not require an instance to be called. As to what can be achieved by placing the main method in an abstract class, well nothing more or less than placing it in any other class.

    Typically, the main method is either placed in a class of its own or in a class that is central to the application. If that class happens to be abstract, so be it.

提交回复
热议问题