错位的构造(Java)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15665860/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
misplaced constructs (Java)
提问by user2216816
public void drawBoard(){
System.out.println(P1 + "|" + P2 + "|" + P3 + "|");
System.out.println(P4 + "|" + P5 + "|" + P6 + "|");
System.out.println(P7 + "|" + P8 + "|" + P9 + "|");
}
I get an underline under "public void drawBoard()" saying "syntax error on token(s) misplaced construct(s)"
我在“public void drawBoard()”下看到一个下划线,上面写着“token(s) misplaced constructor(s)的语法错误”
I looked through the internet and through my Java text book and can not come up with a solution. Any help will be appreciated. Thank you, Allyn
我浏览了互联网和我的 Java 教科书,但找不到解决方案。任何帮助将不胜感激。谢谢你,阿林
回答by NPE
The
这
public void drawBoard() {
must appear directly inside a class definition.
必须直接出现在类定义中。
If there is a method right before drawBoard()
, make sure that you've closed all of its curly braces.
如果之前有一个方法drawBoard()
,请确保您已经关闭了它的所有花括号。