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

前端 未结 17 1460
有刺的猬
有刺的猬 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条回答
  •  -上瘾入骨i
    2020-11-22 00:16

    String[] args means an array of sequence of characters (Strings) that are passed to the "main" function. This happens when a program is executed.

    Example when you execute a Java program via the command line:

    java MyProgram This is just a test

    Therefore, the array will store: ["This", "is", "just", "a", "test"]

提交回复
热议问题