问题
Should not they have used . to end a statement. They could use -> to call a method. Was this just a oversight? Or there is some deeper going on here?
回答1:
Java picked the semicolon to have a syntax similar to C and C++.
C++ picked it to have a syntax similar to C.
And I would guess that C picked the semicolon because B, ALGOL and Pascal already used it, and there was no reason not to use an already accepted convention.
回答2:
EDIT: see https://softwareengineering.stackexchange.com/questions/139482/why-are-statements-in-many-programming-languages-terminated-by-semicolons#139485
... so people understand the comment (and negs), this was the original:
"Additionally, the semicolon stands for a NOP (no operation or null command) in C/C++" might give a clue as to why it's common
http://en.wikipedia.org/wiki/Semicolon#Computing_usage
来源:https://stackoverflow.com/questions/10254588/why-they-used-to-end-statements-in-java-c