web analytics

What is Command-Line Argument in java?

command-line Argument

Command-line Argument

Command-line argument is a method which user will give inputs through the console(command prompt) using commands.The argument accepted by main method is known as command line argument.

  • The main method of java only access array of string as an argument.
  • The argument passed from the console can be received in the JAVA program and it can be used as an input.
  • Bide fault the length of command line argument in C or C++ is 1.
  • In java the length of command line argument is 0.
  • Length is a predefined variable which always return the size of the array in java.


class Test


public static void main(String[] args)





O/P:-depends upon input

Related Posts

Leave a Reply

Your email address will not be published.