- 令牌上的语法错误“。”,@期望在此令牌之后 [英] - Syntax error on token ".", @ expected after this token

查看:715
本文介绍了 - 令牌上的语法错误“。”,@期望在此令牌之后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几天前,我的Eclipse在Windows更新之前工作正常。现在我在Eclipse中尝试任何事情时都会收到错误消息。只是一个简单的程序,因为这将显示一堆错误消息:

  package lab6; 

public class Hellomsg {
System.out.println(Hello。);

}

这些是我在同一行收到的错误,有我的

 System.out.println:
此行上的多个标记

- 语法错误,插入)完成MethodDeclaration
- 令牌上的语法错误。,@这个标记之后的预期
- 语法错误,插入标识符(完成MethodHeaderName


解决方案

你不能只是在类中间浮动语句在Java中,您需要将它们放在方法中:

  package lab6; 

public class Hellomsg {
public void myMethod(){
System.out.println(Hello。);
}
}
pre>

static 块:

  package lab6; 

public class Hellomsg {
static {
System.out.println(Hello。);
}
}


My Eclipse worked fine a couple of days ago before a Windows update. Now I get error messages whenever I'm trying to do anything in Eclipse. Just a simple program as this will display a bunch of error messages:

package lab6;

public class Hellomsg {
    System.out.println("Hello.");

}

These are the errors I receive on the same line as I have my

"System.out.println":
"Multiple markers at this line

- Syntax error, insert ")" to complete MethodDeclaration
- Syntax error on token ".", @ expected after this token
- Syntax error, insert "Identifier (" to complete MethodHeaderName"

解决方案

You can't just have statements floating in the middle of classes in Java. You either need to put them in methods:

package lab6;

public class Hellomsg {
    public void myMethod() {
         System.out.println("Hello.");
    }
}

Or in static blocks:

package lab6;

public class Hellomsg {
    static {
         System.out.println("Hello.");
    }
}

这篇关于 - 令牌上的语法错误“。”,@期望在此令牌之后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆