+ 1
How did the code not give an error
6 Answers
+ 11
Coder #1
Regarding code quality, I also strongly believe that the semicolon (or any other explicit statement separator) helps with readability, as it clearly communicates the end of the statement.
A statement is a unit of instruction (a line). In Java, that line ends with semicolon (;)
So, yes, in your case you don't have any declaration ( int i; ) or expressions statements in code before semicolon! There's a "blank line", and it's end with (;)
+ 10
Coder #1 đYou are welcome! đ
I'm glad if I helped! đ
+ 9
Coder #1
Most, but not all, Java statements must end with a semicolon.
The basic rule is that declaration and expression statements must end with a semicolon, but most other statement types do not.
--> You don't have any declaration or expression statements in you code!!
// before semicolon (;)
+ 8
Semicolons simply terminate statements. Lines mean nothing to the javac compiler. Practicing proper indentation will make your code more readable, especially when your code blocks contain a lot of statements.
https://code.sololearn.com/c59CIZ1qFj13/?ref=app
+ 1
Danijel IvanoviÄ you saying that the semicolon is terminating a blank line ??
+ 1
Danijel IvanoviÄ thank you very much
You've helped me alot