简体   繁体   English

除了'string [] args'之外,java的main方法中还有其他参数吗?

[英]Is there any other parameter in the main method of java other than 'string[] args'?

In java, for a class having 在Java中,对于具有

public static void main(String[] args){

}

Is there any further arguments after String[] args String[] args之后是否还有其他String[] args

public static void main(String[] args | any_arguments_here? ){

}

All the parameters you pass will be receive only in that string array. 您传递的所有参数将仅在该字符串数组中接收。

In short, No. 简而言之,不。

What ever you pass in the command it will be held by args array. 无论您在命令中传递什么,它将由args数组保存。 eg if you write java classname Text1 Text2 , args[0] will contain Text1 and args[1] will contain Text2 例如,如果您编写java classname Text1 Text2 ,则args[0]将包含Text1,而args[1]将包含Text2

The answer is no. 答案是不。

This is a trick interview question to trap experienced C/C++ programmers pretending to be Java programmers. 这是一个技巧性的面试问题,目的是诱使经验丰富的C / C ++程序员冒充Java程序员。

In C/C++ you can declare (and receive from the runtime bootstrap libraries) an 'env' pointer after 'argv', but it is rarely used because it duplicates functionality in the getenv() call. 在C / C ++中,您可以在“ argv”之后声明(并从运行时引导程序库接收)“ env”指针,但是很少使用它,因为它重复了getenv()调用中的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM