'cant recognize the characters in an array, says "error cannot find symbol"

I am trying to get a program to pick an element at random from an array, but I cant initialize the array. every time I run it it points at all of the elements says it doesn't recognize them.

public CountLetters(int rows, int cols, String[] vals)
    {
    char matrix[][] = new char[rows][cols];
    
    char[] source = {a,b,c,d,e,f,g};
     
    for(int i = 0; i < cols; i++){      
            for(int j = 0; j < row; j++){    
             matrix[i][j] = math.random(source);    
            }        
        }  
  }


Solution 1:[1]

What is the exact error message?

But I suspect this line is the problem: char[] source = {a,b,c,d,e,f,g}

a, b, c, d, e, f, and g are symbols that are defined nowhere.

If you mean the first 7 letters of the English alphabet, they need to be written as { 'a', 'b', 'c', 'd', 'e', 'f', 'g' }

For what it's worth, this will give you a 'no such symbol' error from the compiler, not from running the program, which is not possible until the program source is correct (well, some IDEs will let you run an invalid program but that only means it'll fail later).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user15187356