In each Java program there is a method, public static void main (string[] args) method, this parameter for a long time did not understand, but carefully, it is quite simple, all the parameters of the method is a truth, And this main method is different: It is the first one to run in all methods, so there is no other way to pass parameters, so you need to rely on the runtime command line input parameters, so string args, received command line input,
Package test_main;
public class Test_main {
public static void Main (string[] args) {
System.out.println ("Args[0" is "+ args[0]);
System.out.println ("Args[1" is "+ args[1]);
System.out.println ("args[2] is");
}
}
Write a test program, run on Eclipse, the past is a click to run on the line, today tried a few times, and then put the command line to run (cmd that), compile: Javac Test.java run: Java Test Hello World display:
Args[0] is Hello
ARGS[1] is world
ARGS[2] is
Is can run, thought: Eclipse so strong This certainly can do, later on-line a check, in fact very simple, is to open the Debug configuration inside the run, inside the arguments input you want to input parameters, and then save, come out click the Run button, Ok
The results come out and show the parameters just entered
Args[0] is Hello
ARGS[1] is world
ARGS[2] is
String[in Java] args