java.lang.OutOfMemoryError(超出GC开销限制)

java.lang.OutOfMemoryError(超出GC开销限制),java,out-of-memory,Java,Out Of Memory,当我尝试运行TestRun时,我得到了以下错误。我试了很多,但都没找到。帮助我!我得到了内存不足的错误Java堆。 运行下面的代码也需要更多的时间来运行,最后显示错误,如下所示。如何使这段代码正确?调试这对我来说非常困难。线程主java.lang.OutOfMemoryError中的异常:java堆空间 package website; import java.util.ArrayList; import Combination.averageM; import Combination.bo

当我尝试运行TestRun时,我得到了以下错误。我试了很多,但都没找到。帮助我!我得到了内存不足的错误Java堆。 运行下面的代码也需要更多的时间来运行,最后显示错误,如下所示。如何使这段代码正确?调试这对我来说非常困难。线程主java.lang.OutOfMemoryError中的异常:java堆空间

package website;

import java.util.ArrayList;

import Combination.averageM;
import Combination.boatandstreamM;
import Combination.fractionsM;
import Combination.interestM;
import Combination.measurementM;
import Combination.numberM;
import Combination.percentageM;
import Combination.profitandlossM;
import Combination.simplificationM;
import Combination.timeanddistanceM;
import Combination.timeandwM;

public class ArrayOfSums {

    ArrayList<sums> als;
    String Q, A, scale, finalvalue;
    double fv;
    NewOptions pencil = new NewOptions();
    sums sumsObj;

    public ArrayList<sums> giveArrayOfSums(int x) {

        als = new ArrayList<sums>();
        int n = 0;
        switch (x) {

            case 1:
                simplificationM pen = new simplificationM();

                while (n <= 19) {

                    pen.simplificationM();
                    pencil.optionsCreator(pen.fv, pen.scale);
                    sumsObj = new sums(pen.Q, pen.A, pen.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 2:
                numberM pen1 = new numberM();

                while (n <= 19) {

                    pen1.numberM();
                    pencil.optionsCreator(pen1.fv, pen1.scale);
                    sumsObj = new sums(pen1.Q, pen1.A, pen1.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 3:
                percentageM pen2 = new percentageM();

                while (n <= 19) {

                    pen2.percentageM();
                    pencil.optionsCreator(pen2.fv, pen2.scale);
                    sumsObj = new sums(pen2.Q, pen2.A, pen2.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 4:
                numberM pen3 = new numberM();

                while (n <= 19) {

                    pen3.numberM();
                    pencil.optionsCreator(pen3.fv, pen3.scale);
                    sumsObj = new sums(pen3.Q, pen3.A, pen3.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 5:
                fractionsM pen4 = new fractionsM();

                while (n <= 19) {

                    pen4.fractionsM();
                    pencil.optionsCreator(pen4.fv, pen4.scale);
                    sumsObj = new sums(pen4.Q, pen4.A, pen4.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 6:
                profitandlossM pen5 = new profitandlossM();

                while (n <= 19) {

                    pen5.profitandlossM();
                    pencil.optionsCreator(pen5.fv, pen5.scale);
                    sumsObj = new sums(pen5.Q, pen5.A, pen5.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 7:
                averageM pen6 = new averageM();

                while (n <= 19) {

                    pen6.averageM();
                    pencil.optionsCreator(pen6.fv, pen6.scale);
                    sumsObj = new sums(pen6.Q, pen6.A, pen6.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 8:
                timeandwM pen7 = new timeandwM();

                while (n <= 19) {

                    pen7.timeandwM();
                    pencil.optionsCreator(pen7.fv, pen7.scale);
                    sumsObj = new sums(pen7.Q, pen7.A, pen7.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 9:
                timeanddistanceM pen8 = new timeanddistanceM();

                while (n <= 19) {

                    pen8.timeanddistanceM();
                    pencil.optionsCreator(pen8.fv, pen8.scale);
                    sumsObj = new sums(pen8.Q, pen8.A, pen8.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 10:
                boatandstreamM pen9 = new boatandstreamM();

                while (n <= 19) {

                    pen9.boatandstreamM();
                    pencil.optionsCreator(pen9.fv, pen9.scale);
                    sumsObj = new sums(pen9.Q, pen9.A, pen9.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 11:
                interestM pen11 = new interestM();

                while (n <= 19) {

                    pen11.interestM();
                    pencil.optionsCreator(pen11.fv, pen11.scale);
                    sumsObj = new sums(pen11.Q, pen11.A, pen11.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 12:
                measurementM pen12 = new measurementM();

                while (n <= 19) {

                    pen12.measurementM();
                    pencil.optionsCreator(pen12.fv, pen12.scale);
                    sumsObj = new sums(pen12.Q, pen12.A, pen12.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

        }

        return als;

    }

}
类测试运行:

package website;

import java.util.ArrayList;

public class TestRun {

    /**
     * @param args
     */
    public static void main(final String[] args) {
        ArrayOfSums SumsTable = new ArrayOfSums();
        //session.setAttribute("sumtin",SumsTable.giveArrayOfSums(8));

        ArrayList<sums> SumsSet = (ArrayList<sums>) SumsTable.giveArrayOfSums(8);
        sums gotSum = (sums) SumsSet.get(1);

        System.out.println(gotSum.Question);

    }
}

使用-Xmx和-Xms选项运行应用程序时,更改jvm中的java堆大小 详情如下:

java -Xmx512M -Xms512M TestRun 

使用-Xmx和-Xms选项运行应用程序时,更改jvm中的java堆大小 详情如下:

java -Xmx512M -Xms512M TestRun 
当Java虚拟机由于内存不足而无法分配对象,并且垃圾回收器无法提供更多内存时抛出

要消除此问题,可以在jvm中增加以下参数:

Xms-最小堆大小 -Xms选项设置初始和最小Java堆大小。爪哇 堆“heap”是内存中存储内存块的部分 分配给对象并在垃圾收集期间释放

Xmx-最大堆大小 此选项设置最大Java堆大小。Java堆 “堆”是内存中分配内存块的部分 在垃圾收集过程中释放对象。视乎 您正在运行的操作系统的类型,以及您可以实现的最大值 Java堆的设置可能会有所不同

有关详细信息,当Java虚拟机由于内存不足而无法分配对象,并且垃圾收集器无法提供更多内存时,将抛出visit

要消除此问题,可以在jvm中增加以下参数:

Xms-最小堆大小 -Xms选项设置初始和最小Java堆大小。爪哇 堆“heap”是内存中存储内存块的部分 分配给对象并在垃圾收集期间释放

Xmx-最大堆大小 此选项设置最大Java堆大小。Java堆 “堆”是内存中分配内存块的部分 在垃圾收集过程中释放对象。视乎 您正在运行的操作系统的类型,以及您可以实现的最大值 Java堆的设置可能会有所不同

欲了解更多信息,请访问

调试这对我来说非常困难。线程主java.lang.OutOfMemoryError中的异常:java堆空间

package website;

import java.util.ArrayList;

import Combination.averageM;
import Combination.boatandstreamM;
import Combination.fractionsM;
import Combination.interestM;
import Combination.measurementM;
import Combination.numberM;
import Combination.percentageM;
import Combination.profitandlossM;
import Combination.simplificationM;
import Combination.timeanddistanceM;
import Combination.timeandwM;

public class ArrayOfSums {

    ArrayList<sums> als;
    String Q, A, scale, finalvalue;
    double fv;
    NewOptions pencil = new NewOptions();
    sums sumsObj;

    public ArrayList<sums> giveArrayOfSums(int x) {

        als = new ArrayList<sums>();
        int n = 0;
        switch (x) {

            case 1:
                simplificationM pen = new simplificationM();

                while (n <= 19) {

                    pen.simplificationM();
                    pencil.optionsCreator(pen.fv, pen.scale);
                    sumsObj = new sums(pen.Q, pen.A, pen.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 2:
                numberM pen1 = new numberM();

                while (n <= 19) {

                    pen1.numberM();
                    pencil.optionsCreator(pen1.fv, pen1.scale);
                    sumsObj = new sums(pen1.Q, pen1.A, pen1.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 3:
                percentageM pen2 = new percentageM();

                while (n <= 19) {

                    pen2.percentageM();
                    pencil.optionsCreator(pen2.fv, pen2.scale);
                    sumsObj = new sums(pen2.Q, pen2.A, pen2.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 4:
                numberM pen3 = new numberM();

                while (n <= 19) {

                    pen3.numberM();
                    pencil.optionsCreator(pen3.fv, pen3.scale);
                    sumsObj = new sums(pen3.Q, pen3.A, pen3.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 5:
                fractionsM pen4 = new fractionsM();

                while (n <= 19) {

                    pen4.fractionsM();
                    pencil.optionsCreator(pen4.fv, pen4.scale);
                    sumsObj = new sums(pen4.Q, pen4.A, pen4.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 6:
                profitandlossM pen5 = new profitandlossM();

                while (n <= 19) {

                    pen5.profitandlossM();
                    pencil.optionsCreator(pen5.fv, pen5.scale);
                    sumsObj = new sums(pen5.Q, pen5.A, pen5.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 7:
                averageM pen6 = new averageM();

                while (n <= 19) {

                    pen6.averageM();
                    pencil.optionsCreator(pen6.fv, pen6.scale);
                    sumsObj = new sums(pen6.Q, pen6.A, pen6.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 8:
                timeandwM pen7 = new timeandwM();

                while (n <= 19) {

                    pen7.timeandwM();
                    pencil.optionsCreator(pen7.fv, pen7.scale);
                    sumsObj = new sums(pen7.Q, pen7.A, pen7.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 9:
                timeanddistanceM pen8 = new timeanddistanceM();

                while (n <= 19) {

                    pen8.timeanddistanceM();
                    pencil.optionsCreator(pen8.fv, pen8.scale);
                    sumsObj = new sums(pen8.Q, pen8.A, pen8.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 10:
                boatandstreamM pen9 = new boatandstreamM();

                while (n <= 19) {

                    pen9.boatandstreamM();
                    pencil.optionsCreator(pen9.fv, pen9.scale);
                    sumsObj = new sums(pen9.Q, pen9.A, pen9.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 11:
                interestM pen11 = new interestM();

                while (n <= 19) {

                    pen11.interestM();
                    pencil.optionsCreator(pen11.fv, pen11.scale);
                    sumsObj = new sums(pen11.Q, pen11.A, pen11.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 12:
                measurementM pen12 = new measurementM();

                while (n <= 19) {

                    pen12.measurementM();
                    pencil.optionsCreator(pen12.fv, pen12.scale);
                    sumsObj = new sums(pen12.Q, pen12.A, pen12.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

        }

        return als;

    }

}
这不是一个可以调试的问题。对于内存限制,您使用的内存太多。没有一行代码可能导致此问题

相反,您需要使用探查器来确定内存的使用位置。我建议您尝试将最大内存增加到略低于主内存的一半,并附加一个探查器VisualVM总比什么都没有好,并查看对象是否保留在哪里

如果您使用商业探查器,这将运行得更好,并且更清楚问题所在。我使用你的工具包,你可以免费获得评估许可证

我错过了开关箱n++内的增量运算符。所以循环永远不会结束

我会养成像这样使用for循环的习惯

for(int i = 0; i <= 19; i++)
调试这对我来说非常困难。线程主java.lang.OutOfMemoryError中的异常:java堆空间

package website;

import java.util.ArrayList;

import Combination.averageM;
import Combination.boatandstreamM;
import Combination.fractionsM;
import Combination.interestM;
import Combination.measurementM;
import Combination.numberM;
import Combination.percentageM;
import Combination.profitandlossM;
import Combination.simplificationM;
import Combination.timeanddistanceM;
import Combination.timeandwM;

public class ArrayOfSums {

    ArrayList<sums> als;
    String Q, A, scale, finalvalue;
    double fv;
    NewOptions pencil = new NewOptions();
    sums sumsObj;

    public ArrayList<sums> giveArrayOfSums(int x) {

        als = new ArrayList<sums>();
        int n = 0;
        switch (x) {

            case 1:
                simplificationM pen = new simplificationM();

                while (n <= 19) {

                    pen.simplificationM();
                    pencil.optionsCreator(pen.fv, pen.scale);
                    sumsObj = new sums(pen.Q, pen.A, pen.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 2:
                numberM pen1 = new numberM();

                while (n <= 19) {

                    pen1.numberM();
                    pencil.optionsCreator(pen1.fv, pen1.scale);
                    sumsObj = new sums(pen1.Q, pen1.A, pen1.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 3:
                percentageM pen2 = new percentageM();

                while (n <= 19) {

                    pen2.percentageM();
                    pencil.optionsCreator(pen2.fv, pen2.scale);
                    sumsObj = new sums(pen2.Q, pen2.A, pen2.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 4:
                numberM pen3 = new numberM();

                while (n <= 19) {

                    pen3.numberM();
                    pencil.optionsCreator(pen3.fv, pen3.scale);
                    sumsObj = new sums(pen3.Q, pen3.A, pen3.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 5:
                fractionsM pen4 = new fractionsM();

                while (n <= 19) {

                    pen4.fractionsM();
                    pencil.optionsCreator(pen4.fv, pen4.scale);
                    sumsObj = new sums(pen4.Q, pen4.A, pen4.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 6:
                profitandlossM pen5 = new profitandlossM();

                while (n <= 19) {

                    pen5.profitandlossM();
                    pencil.optionsCreator(pen5.fv, pen5.scale);
                    sumsObj = new sums(pen5.Q, pen5.A, pen5.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 7:
                averageM pen6 = new averageM();

                while (n <= 19) {

                    pen6.averageM();
                    pencil.optionsCreator(pen6.fv, pen6.scale);
                    sumsObj = new sums(pen6.Q, pen6.A, pen6.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 8:
                timeandwM pen7 = new timeandwM();

                while (n <= 19) {

                    pen7.timeandwM();
                    pencil.optionsCreator(pen7.fv, pen7.scale);
                    sumsObj = new sums(pen7.Q, pen7.A, pen7.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 9:
                timeanddistanceM pen8 = new timeanddistanceM();

                while (n <= 19) {

                    pen8.timeanddistanceM();
                    pencil.optionsCreator(pen8.fv, pen8.scale);
                    sumsObj = new sums(pen8.Q, pen8.A, pen8.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 10:
                boatandstreamM pen9 = new boatandstreamM();

                while (n <= 19) {

                    pen9.boatandstreamM();
                    pencil.optionsCreator(pen9.fv, pen9.scale);
                    sumsObj = new sums(pen9.Q, pen9.A, pen9.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3, pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 11:
                interestM pen11 = new interestM();

                while (n <= 19) {

                    pen11.interestM();
                    pencil.optionsCreator(pen11.fv, pen11.scale);
                    sumsObj = new sums(pen11.Q, pen11.A, pen11.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

            case 12:
                measurementM pen12 = new measurementM();

                while (n <= 19) {

                    pen12.measurementM();
                    pencil.optionsCreator(pen12.fv, pen12.scale);
                    sumsObj = new sums(pen12.Q, pen12.A, pen12.finalvalue, pencil.jRadioButton1, pencil.jRadioButton2, pencil.jRadioButton3,
                            pencil.jRadioButton4);
                    als.add(sumsObj);
                }
                break;

        }

        return als;

    }

}
这不是一个可以调试的问题。对于内存限制,您使用的内存太多。没有一行代码可能导致此问题

相反,您需要使用探查器来确定内存的使用位置。我建议您尝试将最大内存增加到略低于主内存的一半,并附加一个探查器VisualVM总比什么都没有好,并查看对象是否保留在哪里

如果您使用商业探查器,这将运行得更好,并且更清楚问题所在。我使用你的工具包,你可以免费获得评估许可证

我错过了开关箱n++内的增量运算符。所以循环永远不会结束

我会养成像这样使用for循环的习惯

for(int i = 0; i <= 19; i++)

当堆中使用的内存高于允许的内存或者对象(如列表)变得太大以至于超过JVM分配的内存时,就会发生这种情况。
这可以通过处理数组来解决,比如在不需要对象时清空它们、使用垃圾收集器刷新内存、尝试不在循环中使用数组以及简单地处理堆栈。除非绝对必要,否则简单地增加JVM允许的内存是不好的做法。

当堆中使用的内存高于允许的内存或者对象(如列表)变得太大以至于超过JVM分配的内存时,就会发生这种情况。 这可以通过处理数组来解决,比如在不需要对象时清空它们、使用垃圾收集器刷新内存、尝试不在循环中使用数组以及简单地处理堆栈。简单地说我是个坏习惯
除非绝对必要,否则请增加JVM允许的内存。

由于JVM内存不足,因此出现此错误。您需要通过设置JVM参数来增加java堆大小。 我想问题可能在这里

 while (n <= 19) {

                pen.  simplificationM ();
                pencil.optionsCreator(pen.fv, pen.scale);

                sumsObj = new sums(pen.Q, pen.A, pen.finalvalue 
                                  , pencil.jRadioButton1, pencil.jRadioButton2
                                  , pencil.jRadioButton3, pencil.jRadioButton4);
                als.add(sumsObj);
                n++;//added to increase value of n in each iteration
            }
            break;

在上面的代码中,您没有增加n的值。因此,当您遇到这个错误时,因为JVM内存不足。您需要通过设置JVM参数来增加java堆的大小。 我想问题可能在这里

 while (n <= 19) {

                pen.  simplificationM ();
                pencil.optionsCreator(pen.fv, pen.scale);

                sumsObj = new sums(pen.Q, pen.A, pen.finalvalue 
                                  , pencil.jRadioButton1, pencil.jRadioButton2
                                  , pencil.jRadioButton3, pencil.jRadioButton4);
                als.add(sumsObj);
                n++;//added to increase value of n in each iteration
            }
            break;


在上面的代码中,您并没有增加n的值。所以,在ArrayOfSums类中,当u在while循环中的哪个位置增加n时???在开关盒内。我最后应该输入n++。Stackoverflow.com不是构建更好的Stackoverflows的指南。@PeterRader这不是堆栈溢出,而是堆溢出-@chrylis很明显,这是发布到错误的交换中的。在你的while循环中,u在哪里增加n???在ArrayOfSums类的开关盒中。我最后应该输入n++。Stackoverflow.com不是构建更好的Stackoverflows的指南。@PeterRader这不是堆栈溢出,而是堆溢出-@很明显,这封信当时寄错了。谢谢你的帮助。我自己也发现了。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持,谢谢你的帮助。我自己也发现了。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持,谢谢你的帮助。我自己也发现了。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持,谢谢你的帮助。我自己也发现了。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持,谢谢你的帮助。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持。@Thennarasuravandran我已经更新了我的答案。您想限制局部变量的范围。谢谢您的帮助。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。这导致了这个错误。谢谢你的支持。@Thennarasuravandran我已经更新了我的答案。您想限制局部变量的范围。谢谢您的帮助。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。我刚才找到了。谢谢你的帮助。我错过了开关箱n++内的增量运算符。所以循环永远不会结束。我刚才找到了。谢谢你谢谢你的帮助。谢谢你,谢谢你的帮助。非常感谢。