Compiler doesn't complain when I ended a line with two semicolons. Why?

后端 未结 7 2172
不思量自难忘°
不思量自难忘° 2021-01-19 01:29

I thought bad thing would happen when I ended a line like this. But compiler didn\'t even complain. Does anybody have an idea, why this is legal in java.

displ

7条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-19 02:00

    ; represents the empty statement or you can say, it's represent termination line of a any statement in Java, even if you put more than one it's valid in Java. Compiler will not gives you any error because this is valid. even the below statement is also valid:

    System.out.println("HI");;;;;;;;
    

提交回复
热议问题