简体   繁体   中英

why eclipse sometimes auto adds “*/”?

I'm a new user of eclipse 3.7 and dont know why eclipse always auto adds "*/" when I didnt notice. So I'm wondering why this happened? I haven't catch when it happens since when I write the same pieces of the code the second time the problem disapears.Can someone tell me how to solve it? for example,this following really annoys me

public void addBall()
{
    try
    {
        Ball ball = new Ball();
        comp.add(ball);

        for (int i = 1; i <= STEPS; i++)
        {
            ball.move(comp.getBounds());
            comp.paint(comp.getGraphics());
            Thread.sleep(DELAY);
        }
    }
   */
    catch (InterruptedException e)
    {
    }
}

The problem occurred when I press "{" following the word try . It seems only happens when the corresponding "}" is out of current view, however I'm not really sure.Plus,the compiler didnt give me any warnings.

I'd look at the Java code templates - possibly you triggered something there. The defined templates can be found in Preferences, the Java/Editor/Templates page.

At first look at the try template whether it contains the */; or look for similar patterns as well.

默认情况下,当您输入“ / *”并按Enter时,Eclipse会自动添加“ * /”,就像自动添加右括号一样。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM