What's the point of String[] args in Java?

前端 未结 7 1782
感情败类
感情败类 2021-01-17 06:50

Whenever you declare the main method in a class, you always have to do a String array called \"args\". What\'s the point? Unless I live under a rock, command li

相关标签:
7条回答
  • 2021-01-17 07:15

    I actually have no idea why it's required, other than to say that it is a syntactical convention. In the same way that a function is (defined function-name()) in Lisp/Scheme, or there are do..end blocks in Ruby, the syntax of a Java Main function is with String[] args.

    As for not using command line arguments, it's entirely dependent on the program. Entirely. I write programs in java all the time that take command line arguments; it's just a question of what you're trying to accomplish.

    0 讨论(0)
提交回复
热议问题