part of my program includes my boolean 2d array: boolean[][] matrix = new boolean[V][V];i want to iterate through the vertex and check if it is true but am getting error: cannot convert from boolean[] to boolean. casting (boolean) does not help. i have also tried boolean[v][w] == true.
here is where i am having the problem:

public int degree(int v) {
        int degreeCounter = 0;
        for(int i = 0; i < v; i++){
            if(matrix[v]){ //<---- problem here!
                degreeCounter++;
            }
        }
        return degreeCounter;
    }

Any insight is greatly appreciated!

matrix is a 2D array (strictly: an array of arrays) so you need two indexes to get to a single element in matrix. I don't know excatly what you tried, but you will need something like
if (matrix[i][j]) ...
where i and j are integers, integer expressions, or anything else that the compiler can convert to int.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.