与(if)条件无关的错误:令牌无效字符的语法错误,删除此令牌

时间:2014-02-05 14:26:15

标签: java

我正在处理一个我遇到此错误的Java代码: 令牌上的语法错误无效字符删除此令牌 我不知道如何解决这个问题。 原始代码:

if ((base[i - 1][j] != 0) &&‌ (base[i - 1][j] != c))//the error is on this line
{
    for (int p = 1; p < i; p++) {
        if (base[i - p - 1][j] != 0) {
            break;
        }
        if (base[i - p - 1][j] != c) {
            break;
            location[0] = i - p - 1;
            location[1] = j;
        }
        if (location != null) {
            int[] temploc1 = new int[2];
            int[] temploc2 = new int[2];
            temploc1[0] = i;
            temploc1[1] = j;
            temploc2[0] = i - p - 1;
            temploc2[1] = j;
            paint(temploc1, temploc2);
        }
    }
}

2 个答案:

答案 0 :(得分:4)

&&与以下空格(unicode = 8204)之间的隐藏字符无效:

if ((base[i-1][j]!=0) &&‌ (base[i-1][j]!=c))//the error is on this line
                        ^

如果删除并重新输入&&(包括空格),它可以正常工作:

if ((base[i-1][j]!=0) && (base[i-1][j]!=c))//the error is on this line

答案 1 :(得分:0)

您可以使用

        int i = 1;
    int[][] base;
    int j = 1;
    int c = 1;
    int base1 = base[i - 1][j ];
    int base2 = base[i - 1][j];
    if (base1!= 0) {
        if (base2!= c) {
        for (int p = 1; p < i; p++) {
            if (base[i - p - 1][j] != 0) {
                break;
            }
            int[] location;
            if (base[i - p - 1][j] != c) {
                break;
                location[0] = i - p - 1;
                location[1] = j;
            }
            if (location != null) {
                int[] temploc1 = new int[2];
                int[] temploc2 = new int[2];
                temploc1[0] = i;
                temploc1[1] = j;
                temploc2[0] = i - p - 1;
                temploc2[1] = j;
                paint(temploc1, temploc2);
            }
        }
        }
    }