Java 令牌“;”上的语法错误,AssignmentOperator无效 私有列表标记=新的ArrayList;

Java 令牌“;”上的语法错误,AssignmentOperator无效 私有列表标记=新的ArrayList;,java,eclipse,assignment-operator,Java,Eclipse,Assignment Operator,我有一些代码,但这给了我一个错误 我使用Eclipse,它在字符的正下方显示一条红色下划线。我不知道为什么。一切似乎都很好。这是全部代码: public class Analyze { protected String text = null; public List<String> tokens = new ArrayList<String>(); // Error is right here. this.tokenize();

我有一些代码,但这给了我一个错误

我使用Eclipse,它在字符的正下方显示一条红色下划线。我不知道为什么。一切似乎都很好。这是全部代码:

public class Analyze {

    protected String text = null;

    public List<String> tokens = new ArrayList<String>(); // Error is right here.

    this.tokenize();

    public Analyze(String txt) {
        // This is the constructor. I will call the class outside with a variable just like method. Just like: Analyze aText = new Analyze("Some texts here.");
        // Then I will call the tokens variable inside the class. (Or am I just doing it wrong?)

        this.text = txt;
    }

    private List<String> tokenize() {
        // Some codes that changes the value of "tokens" variable.
    }
}
我在互联网和这个平台上查看了一下,我通常发现一些逻辑运算符,如,=等,导致了这个问题,但不是

附加编辑 当我改变这些线的位置时,如下所示:

public List<String> tokens = new ArrayList<String>();
protected String text = null; // Then error seems right here.
您的问题在于此.Analyze;。它应该在某种方法中

尽管现在还不清楚这行代码到底应该做什么。

你不能拥有它;在当前位置

您可以这样写,但这也没有任何用处,因为它返回数组列表

public Analyze(String txt) {
    this.text = txt;
    this.tokenize();
}

分析;这是无效的。这条线需要在某种方法中。还有,你想在那里发生什么?该方法返回一个值,但您不使用它。//某些代码区域更改私有令牌变量的值并返回它。事实上,我刚刚看到这看起来很愚蠢,我会编辑代码。我只是编辑了代码。我将令牌公开,以便在类外访问它。方法调用的位置正确。在静态块中之前,不能有这样的方法调用