本文介绍了String [] arg和String [] args之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

String [] args String [] arg 之间是否有区别?

我的任务是在 HelloWorld 程序中拼错某些内容.

My assignment is to misspell certain things in a HelloWorld program.

当我在以下位置将 args 拼写为 arg 时:

When I misspelled args as arg in:

public class HelloWorld {
     public static void main(String[] args) {
          System.out.println("Hello, World");

该程序已编译并正确运行.因此,我试图了解为什么 arg args 一样好.

The program compiled and ran correctly. So I'm trying to understand why arg worked just as well as args.

arg 只是 args 的替代拼写,还是两者之间有区别?

Is arg just an alternate spelling for args, or is there a difference between the two?

我只是尝试将 args 拼写为 ars ,然后程序重新编译并正确运行.我现在肯定很困惑.

I just tried misspelling args as ars, and the program compiled and ran correctly again. I'm definitely confused now.

推荐答案

只要不使用变量,无论将其指定为 args 还是 arg 没有不同.字节码不存储类型的实际名称.它知道分配了一个接受 String [] 的变量.

As long as you are not using the variable, whether you specified it as args or arg makes no difference. The bytecode doesn't store the type actual name. It knows that there is a variable assigned that accepts a String[].

这篇关于String [] arg和String [] args之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 13:14