有可能超载主方法吗? [英] is possible to overload a main method?

查看:137
本文介绍了有可能超载主方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以重载主方法吗?如果是,jvm将从哪个方法开始执行?

is possible to overload a main method? If yes from which method the jvm will start executing?

推荐答案

是的。 main方法可以像Java中的任何其他方法一样重载。

Yes. The main method can be overloaded just like any other method in Java.

main的通常声明是

The usual declaration for main is

public static void main(String[] args) throws Exception;

启动Java应用程序时,它会查找名为 main ',返回类型' void'以及一个字符串数组的单个参数。即你抛出的东西在解析这个方法时并不重要。

When you launch a java application it looks for a static method with the name 'main', return type 'void' and a single argument of an array of Strings. ie what you throw is unimportant in resolving this method.

重载提供了多个具有相同名称但不同参数的方法(可能还有返回类型)。

Overloading is providing multiple methods with the same name but different arguments (and potentially return type).

通过上述解释,我们可以重载主方法。

With the above explaination we can overload the main method.

这篇关于有可能超载主方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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