语法错误:插入}完成ClassBody [英] syntax error: insert } to complete ClassBody

查看:1568
本文介绍了语法错误:插入}完成ClassBody的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个方法,并不断得到我需要包括}在我的方法的最后一个错误。我把}中的错误仍然存​​在!如果我再删除}同样的错误会弹出一个现有的方法;而这个错误是不存在了。换句话说,如果我输入我的最新方法}然后错误在那里停留,只有在那里。如果我删除它,它在重复我以前的方法错误。

 私人无效putThreeBeepers(){
的for(int i = 0;我2;我++){
    putBeeper();
    移动();
}
putBeeper();
}
私人无效的备份(){
回转();
移动();
回转();
   }
 

解决方案

您真的想要去你的文件的顶部,并做适当的和一致的缩进一路底部。

例如...

 私人无效putThreeBeepers()
{
    的for(int i = 0;我2;我++){
        putBeeper();
        移动();
    }

    putBeeper();
}

私人无效的备份()
{
    回转();
    移动();
    回转();
}
 

奇怪的是,沿线某处,你缺少一个}。您的描述不超清晰,但如果您发布的code是如何实际已经在你的文件,那么可能你只是错过了一些地方格式化...和缩差使得它很难被发现。

事实上,该消息被改变是混乱的,但它的东西,你在这种情况下看到的那种。

I created a method and keep getting an error that I need to include a } at the end of my method. I put the } in and the error is still there! If I then delete that } the same error will pop up on a prior method; and that error wasn't there before. in other words, if i type the } on my most recent method then the error stays there and only there. if i delete it, it duplicates that error on my prior method.

private void putThreeBeepers() {
for (int i = 0; i < 2; i++) {
    putBeeper();
    move();
}
putBeeper();
}
private void backUp() {
turnAround();
move();
turnAround();
   }

解决方案

You really want to go to the top of your file and do proper and consistent indention all the way to the bottom.

For example...

private void putThreeBeepers() 
{
    for (int i = 0; i < 2; i++) {
        putBeeper();
        move();
    }

    putBeeper();
}

private void backUp() 
{
    turnAround();
    move();
    turnAround();
}

Odds are, somewhere along the line, you are missing a }. Your description isn't super clear, but if the code you posted is how you actually have it formatted in your file then odds are you just missed something somewhere... and poor indentation makes it very hard to spot.

The fact that the message is changing is confusing, but it is the sort of thing you see in these cases.

这篇关于语法错误:插入}完成ClassBody的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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