In the main method of a program we always use the code as a parameter: String[] args
What does it mean?
In the tutorial of java sun, there is a code following
public static void main(String[] args) {
//this program requires two arguments on the command line
if (args.length == 2) {
//convert strings to numbers
float a = (Float.valueOf(args[0]) ).floatValue();
float b = (Float.valueOf(args[1]) ).floatValue();
//do some arithmetic
System.out.println("a + b = " + (a + b) );
System.out.println("a - b = " + (a - b) );
System.out.println("a * b = " + (a * b) );
System.out.println("a / b = " + (a / b) );
System.out.println("a % b = " + (a % b) );
} else {
System.out.println("This program requires two command-line arguments.");
}
and the output supposed to be like that
a + b = 91.7
a - b = -82.7
a * b = 392.4
a / b = 0.0516055
a % b = 4.5
However i can't get it. I got "This program requires two command-line arguments". Why?