javaguy
javaguy

Reputation: 4442

Why they used ; to end statements in Java/C++

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?

Upvotes: 2

Views: 716

Answers (2)

craniumonempty
craniumonempty

Reputation: 3535

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

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691973

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.

Upvotes: 5

Related Questions