Mona Jalal
Mona Jalal

Reputation: 38155

Debug information is inconsistent in IntelliJ

My program runs and gives the correct answer however I see the following message: enter image description here

Debug information is inconsistent.

Is this something I should worry about? and is so, how can I solve it? This is the whole code for the reference:

/**
 * Created by mona on 3/7/16.
 */
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PascalTriangle {

    public static long biCoeff(int n, int k){
        if (n==k){
            return (long) 1;
        }
        if (n==0){
            return (long) n;
        }

        return (biCoeff(n-1, k-1)+biCoeff(n-1,k));
    }

    public static List<List<Integer>> generate(int numRows) {
        List<List<Integer>> mylist = new ArrayList<>();
        for (int i=0; i<numRows; i++){
            mylist.add(new ArrayList<Integer>());
            for (int j=0; j<=i; j++) {
                mylist.get(i).add((int) biCoeff(numRows, j));
            }

        }
        return mylist;
    }


    public static void main(String[] args){
        List<List<Integer>> l = new ArrayList<>();

        l=generate(5);

        for (List<Integer> list:l){
            System.out.print("[");
            for (Integer i: list){
                System.out.print(i + ",");
            }
            System.out.println("],");
            System.out.println();
        }


    }
}

Upvotes: 3

Views: 5596

Answers (3)

shemerk
shemerk

Reputation: 387

It happened to me during unit test when I tried to debug the tested class. The reason was that I updated the tested class by adding a new bean member, but failed to add it as a @Mock field in the test class.

i.e. I added

private final MyBean myBean;

and had to add to the test:

@Mock 
private final MyBean myBean;

Upvotes: 0

Tony Fraser
Tony Fraser

Reputation: 757

The same thing happens in my scala projects sometimes. Just a few moments ago my project was configured and ran just fine using java 13 configured as java 1.8 but I got the debug inconsistent output. I swapped the SDKs out to run an actual 1.8, instead of 13 playing as 1.8, and that debug inconsistent stuff went away.

That said, I suggest installing SDKMan and pulling down and using a specific version of the SDK. And any SDK you download with SDKMan will start showing up as a potential SDK in your intellij run configuration screen. It's an awesome tool.

Upvotes: 1

Zhivko.Kostadinov
Zhivko.Kostadinov

Reputation: 467

In your code,i do not see problem.What Java version do you use?

Upvotes: 0

Related Questions