撰写某个程序,使它能够接受由命令行(command line)传入的三个引数。为此,你得对代表命令行引数的Strings数组进行索引。

解决方案 »

  1.   

    类的public staitc void main(String[] args)
    {}里边的String[]就是你输入的参数了.
      

  2.   

    package com.bruceeckel.c02.study;public class StringTest {
        public static void main(String[] args) {
            System.out.println("第一个引数为: " + args[0]);
            System.out.println("第二个引数为: " + args[1]);
            System.out.println("第三个引数为: " + args[2]);
        }
    }
    这样是否合理? 有没有更好的写法?
      

  3.   

    最好还是先取得数组的length,再循环。