可以存在在Java程序中两个主要的方法呢? [英] Can there exist two main methods in a Java program?

查看:112
本文介绍了可以存在在Java程序中两个主要的方法呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否出现在Java程序中存在两种主要的方法?
只有像他们的论点的区别:

 公共静态无效的主要(字串[] args)

和第二可

 公共静态无效的主要(StringSecond []参数)

如果它是可能的,这方法将用作入口点?
如何识别呢?请帮助。


解决方案

只要方法的参数(编号(或)类型)是不同的,是的,他们可以。这就是所谓的超载


  

重载方法由数量和传递到方法的参数的类型区分


 公共静态无效的主要(字串[] args)

只有单一的的String [] (或)字符串... 作为参数将被视为主要方法入口点计划。

Can there exist two main methods in a Java program? Only by the difference in their arguments like:

public static void main(String[] args)

and second can be

public static void main(StringSecond[] args)

If it is possible,which Method will be used as the entry point? How to identify this? please help.

解决方案

As long as method parameters (number (or) type) are different, yes they can. It is called overloading.

Overloaded methods are differentiated by the number and the type of the arguments passed into the method

public static void main(String[] args)

only main method with single String[] (or) String... as param will be considered as entry point for the program.

这篇关于可以存在在Java程序中两个主要的方法呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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