main method in the parameters String [] args

When General execute Java programs, we enter the command to execute java HelloWorld.java

In fact, the back also can add parameters in the format of java class name parameter 1 parameter 2 ......

 

1 public class Demo {
2     public static void main(String[] args) {
3         for(int i=0;i<args.length;i++) {
4             System.out.println(args[i]);
5         }
6     }
7 }

 

 

In the IDE, can also be set at run time, eclipse is configured in the run configurations run as inside

Guess you like

Origin www.cnblogs.com/shizunatsu/p/11411525.html