Netbeans 建议将字段转换为最终字段,尽管我修改了该字段

Netbeans is suggesting to convert a field to a final despite the fact that I modify this field

首先,这里是相关代码:

public class AtCounter
{
    private char[][] atMat;
    private int atCount;

    public AtCounter()
    {
        atCount=0;
        atMat= new char[][]{{'@','-','@','-','-','@','-','@','@','@'},
                            {'@','@','@','-','@','@','-','@','-','@'}, 
                            {'-','-','-','-','-','-','-','@','@','@'}, 
                            {'-','@','@','@','@','@','-','@','-','@'}, 
                            {'-','@','-','@','-','@','-','@','-','@'}, 
                            {'@','@','@','@','@','@','-','@','@','@'}, 
                            {'-','@','-','@','-','@','-','-','-','@'}, 
                            {'-','@','@','@','-','@','-','-','-','-'}, 
                            {'-','@','-','@','-','@','-','@','@','@'}, 
                            {'-','@','@','@','@','@','-','@','@','@'}};

    }

    public int countAts(int r, int c)
    {

        if(r<atMat.length && c<atMat[0].length && r>=0 && c>=0 && atMat[r][c]=='@')
        {
            atMat[r][c]='X';
            atCount++;
        }
        else
            if(r-1<atMat.length && r-1>=0)
                countAts(r-1,c);
        else
                if(r+1<atMat.length && r+1>=0)
                    countAts(r+1,c);
        else
                    if(c-1<atMat[0].length && c-1>=0)
                        countAts(r,c-1);
        else
                        if(c+1<atMat[0].length && c+1>=0)
                            countAts(r,c+1);
        return atCount;

    }

请注意,countsAts 方法包含行 atMat[r][c]='X';,它会更改二维数组中元素的值。尽管如此,在行 private char[][] atMat; 上,Netbeans 给了我警告 "Field atMat can be final"。如果我正在修改它的值,为什么这个字段可以是最终的?是不是和我现在修改的代码中的where有关系? Netbeans 是否被窃听(怀疑)?如果有人可以解释警告,我将不胜感激!

您可以更改名称 atMat 引用的对象的内容。 atMat 是一个参考。引用本身可以成为最终的。