Search code examples
javaeclipsedebuggingeclipse-neon

Eclipse Error Debug


I am new on the Eclipse, I am trying to debbug a simple code. But when I start the debug, some error occurs, and I dont understand why.![enter image description here]1

Here tell me that I am using obsolete methods. And have 2 variables that the debbug dont see that is "resultZero" and "resultOne" enter image description here

enter image description here

Exercise22.java

public class Exercise22 {

    public static void main(String[] args){

        int[] A = new int[20];
        float countZero = 0;
        float countOne = 0;
        float resultZero = 0;
        float resultOne = 0;

        for (int i = 0; i<A.length; i++){
            A[i] = (int)Math.round(Math.random() * 1);
            if (A[i] == 0){
                countZero += 1;
                } else {
                countOne += 1;
                }
             }
        for (int i = 0; i<A.length; i++){
        System.out.println("Value: " + A[i]);
        }

        resultZero = (countZero / A.length) * 100;
        resultOne = (countOne / A.length) * 100;

        System.out.println("Zero: " + resultZero + "%");
        System.out.println("One: " + resultOne + "%");

    }
}

Solution

  • This error message indicates that you are doing hot code replace, and that the frames on the stack no longer match the class files in the running VM. Restarting your debug session/target VM should suffice.

    If this does not work.. then the second reason reason could be.. you are running the application before the build complete. Try once that , you can also change setting for that at see Preferences

    Run/Debug > Wait for ongoing build to complete before launching.