Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Eclipse说,,不知道为什么_Java_Eclipse - Fatal编程技术网

Java Eclipse说,,不知道为什么

Java Eclipse说,,不知道为什么,java,eclipse,Java,Eclipse,我不确定,当我在eclipse中运行它时,它会说。现在发生的是,输入Y是一个小于10000的年份,我必须找到在那一年之后的下一年,它有所有不同的数字。例如,2010年将打印2013年,因为2013年是2010年之后的下一年,所有数字都不同 package from1987To2013; public class from1987To2013 { public static void main(String[] args) { //Y is year input

我不确定,当我在eclipse中运行它时,它会说。现在发生的是,输入Y是一个小于10000的年份,我必须找到在那一年之后的下一年,它有所有不同的数字。例如,2010年将打印2013年,因为2013年是2010年之后的下一年,所有数字都不同

package from1987To2013;

public class from1987To2013 {
    public static void main(String[] args) {

        //Y is year input
        int Y = 2011;
        //number of digits in Y
        int length = String.valueOf(Y).length();


        //Turns the Y into an int array arrayY
        String temp = Integer.toString(Y);
        int[] arrayY = new int[temp.length()];
        for (int i = 0; i < temp.length(); i++)
        {
            arrayY[i] = temp.charAt(i) - '0';
        }

        //first for loop
        for (int i = 0; i < 10000; i++) {
            //find every value from Y to 10000
            int a = Y + i;

            //changes if its true or not
            boolean bool = true;

            //this loop goes through once if y = 2, twice if y = 33, thrice if y = 456, four times if y == 4666, etc
            int d = 0;
            for (int b = 0; b < length; b++)
                //d is the b - 1 which will be compared with the position at b
                d = b-1;
                int b = 0;
                //checks if they're all equal
                if (arrayY[d] != (arrayY[b])) {
                } else {
                    bool = false;
                    break;
                }
            if (bool = true){
                System.out.print(a);
        }

        }
    }

}

除了根据@ZouZou的评论更改代码外,我不太清楚为什么,但我不得不更改这一行:

System.out.print(a);

以便从eclipse获得任何输出


p、 您的逻辑不起作用,但至少这会给您输出,以便您现在可以调试它。

注意:如果bool=true{应该是如果bool==true{或者如果bool更简单{d=b-1,当b=0将d设置为-1时,这将用作数组中的索引。您是否尝试调试并单步执行代码?int b=0;bSystem.out.println(a);