java的命令行参数到底怎么用,请给截图和实际的例子

8.2 命令行参数示例(实验)   

public class Test {
    public static void main(String[] args){
        if(args.length==0){
            System.out.println("you don't set command line parameters!");
        }else{
            for (int i=0; i<args.length; i++){
                System.out.println("args[" + i + "] is: " + args[i]);
            }
        } 
    }
}

 

when use eclipse, don't "run as application",directly use "run configurations/run", then add in aguments in program arguments.(当运行eclipse,不要"run as application",而直接用"run configurations/run",然后加上参数在,program arguments.)

 

 

 

result is:

args[0] is: 马克-to-win
args[1] is: 的
args[2] is: 书

下图是有关非eclipse命令行的实验:

 

 

8.3 Arrays of Arrays(1)

An array that contains other arrays as its elements.(一个数组中包含其他的数组作为它的元素)

public class TwoDimentional {
    public static void main(String[] args) {
        char[][] table= new char[2][4];
            char[] row0 = {'A','B','Z','M'};
            char[] row1 = {'C','D','K','L'};
            table[0] = row0;

            table[1] = row1;

            for(int i=0; i<2;i++){
                for(int j=0;j<4;j++){
                    System.out.println(table[i][j]);
                }
            }

    }
}

更多内容请见原文,文章转载自:https://blog.csdn.net/qq_44639795/article/details/103144589

posted @ 2021-01-05 08:43  师徒行者  阅读(142)  评论(0编辑  收藏  举报