Gabriel Gomes
Gabriel Gomes

Reputation: 139

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 + "%");

    }
}

Upvotes: 1

Views: 1993

Answers (2)

A Paul
A Paul

Reputation: 8251

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.

Upvotes: 3

EduardoMaia
EduardoMaia

Reputation: 601

You were trying to change your code in the middle of the debug and eclipse some times launches that error when you run a code and the build isn't complete. Just create a new project and copy your code there. There's a more elegant solucion found here: "https://www.eclipse.org/forums/index.php/t/57630/" but it will only work if you have a eclipse 3.0 or above. SInce you didn't mentioned the version you are using, I found best to give you alternatives.

Upvotes: 2

Related Questions