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

后端 未结 7 2228
不思量自难忘°
不思量自难忘° 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 01:49

    The compiler uses semicolon to denote an 'end of statement'. Having two consecutively ends the statement prior to the first, and then creates a second empty statement.

    Really, you could even do this:

    displayDataMap.put("dateInterval", getDateInterval());;;;;;;;;;;;;;;
    

提交回复
热议问题