集册 Java实例教程 通过命令传递参数

通过命令传递参数

欢马劈雪     最近更新时间:2020-01-02 10:19:05

382
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
通过命令行执行传递参数
/** 
 来自 n  o  w  j  a  v  a . c o m**/

public class Main {

    public static void main(String[] args){

        if(args.length > 0){

            System.out.println("Arguments that were passed to the program: ");

            for (String arg:args){

                System.out.println(arg);

            }

        } else {

            System.out.println("No arguments passed to the program.");

        }

    }

}