What is “String args[]”? parameter in main method Java

前端 未结 17 1462
有刺的猬
有刺的猬 2020-11-21 23:58

I\'m just beginning to write programs in Java. What does the following Java code mean?

public static void main(String[] args)
  • What

17条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 00:02

    args contains the command-line arguments passed to the Java program upon invocation. For example, if I invoke the program like so:

    $ java MyProg -f file.txt
    

    Then args will be an array containing the strings "-f" and "file.txt".

提交回复
热议问题