Java command line arguments

Command line argument is an input or argument to the program when you run the program. In Java, we can take the inputs from the console, and it can be received in the Java program. These inputs are stored as a string array in the main method.

Naturally, it is just a method that was used until Scanner function is not introduced.

There is no restriction limit of Java command line inputs so that you can specify the n number of inputs.

See at the below example



Java Command line 1

In the above example, I have passed x and y as arguments.

Command Line example for passing many arguments



Java Command line 2

As we can see in the above example, I have passed many arguments. It concludes that we can pass more than one argument in a single command line.

Parse method

It is a method that takes String as user input and converts it into various forms like Integer, Float, and Double.

Types of parse method

There are three types of parse method.

  • parseInt();
  • parseDouble();
  • parseFloat();

The parseint() method uses the function Parseint(). It  is a member function in Integer class.

The parseDouble() method uses the function ParseDouble(). It is a member function in Double class.

The parseFloat() method uses the function ParseFloat(). It is a member function in Float class.

All of the parse methods have the same syntax.




Java Command line 3

Pin It on Pinterest

Share This