When would you put a semicolon after a method closing brace?

前端 未结 4 590
轮回少年
轮回少年 2020-12-02 01:43

I\'ve been programming in Java for a while, and I\'ve just come across this syntax for the first time:

public Object getSomething(){return something;}; 
         


        
4条回答
  •  既然无缘
    2020-12-02 02:23

    It's simply an empty statement - it is most likely a typo.

    Consider the fact that in all C-based languages, a statement is terminated with a semicolon. A hanging semicolon like this simply terminates the current statement which in this case is nothing.

提交回复
热议问题