Home > Java > javaTutorial > Using command line arguments

Using command line arguments

王林
Release: 2024-08-13 10:09:18
Original
839 people have browsed it

Using command line arguments

  • The args parameter of the main() method stores the command line arguments passed to the program.

  • Command line arguments are information provided after the program name on the command line during execution.

  • These arguments are stored as strings in a String array passed to main().

  • The following example demonstrates how to display all command-line arguments provided to the program.

Usando argumentos de linha de comando

  • Output below:
    There are 3 command-line arguments.
    They are:
    arg[0]: one
    arg[1]: two
    arg[2]: three

  • Command line arguments are stored in an array, with the first argument at index 0, the second at index 1, and so on.

  • The following example illustrates how to use command-line arguments to receive a person's name.

  • The program searches for this name in a two-dimensional array of strings.

  • If the name is found, the program will display the corresponding phone number.

Usando argumentos de linha de comando

The above is the detailed content of Using command line arguments. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template