【问题标题】:Get the command line arguments in NetBeans 7.1.2在 NetBeans 7.1.2 中获取命令行参数
【发布时间】:2014-03-04 02:59:43
【问题描述】:

我使用的是 NetBeans 7.1.2。我的错误是:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at javaapplication1.JavaApplication1.main(JavaApplication1.java:17)
Java Result: 1

我的程序是:

package javaapplication1;

/**
 *
 * @author Administrator
 */
public class JavaApplication1 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] ar) {
        int a=Integer.parseInt(ar[1]);

        System.out.println(a);
        // TODO: Code application logic here
    }
}

【问题讨论】:

    标签: netbeans command-line-arguments


    【解决方案1】:

    仅供参考,第一个参数是ar[0],例如在ar[0]下面的命令行中是"123"

    java JavaApplication1 123
    

    有关 Java 命令行参数的更多信息,请参阅 this web page

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 1970-01-01
      • 1970-01-01
      • 2021-01-05
      • 2016-05-25
      • 2011-03-29
      相关资源
      最近更新 更多