我不确定为什么会出现此错误。大括号似乎是正确的。另一件事是,同一个程序在 Windows-eclipse 中工作,但在 Mac 的 eclipse 中不工作。可能是什么原因?
import java.util.Vector;
public class Debug
{
private int something = 0;
private Vector list = new Vector();
public void firstMethod()
{
thirdMethod(something);
something = something + 1;
}
public void secondMethod()
{
thirdMethod(something);
something = something + 2;
}
public void thirdMethod(int value)
{
something = something + value;
}
public static void main(String[] args)
{
Debug debug = new Debug();
debug.firstMethod();
debug.secondMethod();
}
}
最佳答案
啊,好的 - 它可能是文件末尾的一个 control-Z 或其他不可打印的字符,在 Windows 中被忽略,但在 Mac 上却没有。您将源代码从 Windows 复制到 Mac。删除最后几个字符并重新输入它们 - 我认为它会消失。不过我不玩 Mac - 我只是猜测。
关于java - token "Invalid Character"语法错误,删除此 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7129371/