使用Java的静态方法main有什么实际区别? [英] Any practical difference in the use of Java's static method main?

查看:147
本文介绍了使用Java的静态方法main有什么实际区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有以下Java类:

If I have the following Java class :

public class MyClass
{
  ...

  public static void main(String[] args) 
  {
   ...
  }
}

如果我通过以下两种不同的方式称呼它,有什么实际的区别吗?

Is there any practical difference if I call it in the 2 different ways below ?

[1] new Stock_Image_Scanner().main(null);
[2] Stock_Image_Scanner.main(null);

推荐答案

在第一个构造函数中执行该构造函数.在第二个中没有.

In the first one the constructor gets executed. In the second one it does not.

这篇关于使用Java的静态方法main有什么实际区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆