反正闲着也是闲着
public static void main(String[] args) {
if(args.length == 2) {
if(args[0].equals("start")) {
Double D = new Double(args[1]);
double d = D.doubleValue();
int count = Math.abs((int)d);
int[] datas = new int[count];
for(int i = 0; i < count; i ++) {
datas[i] = (int)i * (int)d;
}
} else if(args[0] == "end") {
System.out.println("GoodBye!");
}
}
}

解决方案 »

  1.   

    先看到一个缩进的问题
    缩进应该是四个空格args.getLength() -->>>args.lengthdatas[i] = (int)i * d;-->>>(int)(i * d)
      

  2.   

    args[0] == "end"---->>>>args[0].equals("end");Double D = args[1];------>>>>>>>Double D = new Double(args[1]);
      

  3.   

    楼主以前肯定是用c or c++用多了!
    java和那些有些地方还是不一样的!
      

  4.   

    public static void main(String[] args) {
    if(args.getLength() == 2) { *********************应该用args.length 
    if(args[0].equals("start")) {
    Double D = args[1]; *************Double D = new Double(args[1]);
    double d = D.doubleValue();
    int count = Math.abs((int)d);
    int[] datas = new int[];****************** 这里没做初期化
    for(int i = 0; i < count; i ++) {
    datas[i] = (int)i * d; ********************* datas[i] = (int)(i * d);因为i*d是double
    }
    } else if(args[0] == "end") {*************** args[0].equals("end")因为这样才能比较对象而不是引用
    System.out.println("GoodBye!");
    }
    }
    }
      

  5.   

    public static void main(String[] args) {
    if (args.length == 2) {
    if (args[0].equals("start")) {
    Double D = new Double(args[1]);
    double d = D.doubleValue();
    int count = Math.abs((int) d);
    int[] datas = new int[count];
    for (int i = 0; i < count; i++) {
    datas[i] = (int) (i * d);
    }
    } else if (args[0] == "end") {
    System.out.println("GoodBye!");
    }
    }
    }
      

  6.   

    public static void main(String[] args) {
    if (args.length == 2) {
    if ("start".equalsIgnoreCase(args[0])) {
    Double D = Double.valueOf(args[1]);
    double d = D.doubleValue();
    int count = Math.abs((int) d);
    int[] datas = new int[count];
    for (int i = 0; i < count; i++) {
    datas[i] = (int) (i * d);
    }
    } else if ("end".equalsIgnoreCase(args[0])) {
    System.out.println("GoodBye!");
    }
    }
    }
      

  7.   

    Double D = args[1]; //首先要new Double,还要处理无法转换的情况,如“abc”
    double d = D.doubleValue();
      

  8.   

    if (args[0].equals("start"))
    改为
      if ("start".equals(args[0]))这是好的习惯...
    菜鸟肯定看着很不习惯 :)
      

  9.   

    to:zez
    请问为什么那样写是好习惯?
      

  10.   

    我看着的确很不习惯,什么和什么嘛,呵呵if ("start".equals(args[0]))
    这句话编译器是怎么去编译得,虚拟机如何解释,先后构造了一些什么对象调用了一些什么对象的什么方法,好处在哪里,哪位老鸟来说个明白透彻?
      

  11.   

    if ("start".equals(args[0]))
    这个编译的好处我是不知道,不过至少有这么个好处:
    如果你的args[0] = null,
    那就惨了