[Solved] What’s wrong to have empty lines in Java class? [closed]


Not at all.

Empty lines do not matter at runtime, as the java compiler turns your source code into bytecode in the very first place. The only “consequence” of using empty lines will be the line number information that the compiler can include in the bytecode files. More empty lines, resulting in higher numbers. But that is really of no concern at all.

From that point of view, you strive to use vertical spacing for one purpose, and one purpose only: to communicate intent to human readers of your code. You use empty lines to “group” things that belong together. Of course, you use them with care: too many empty lines don’t help with readability a bit. You don’t want the reader to scroll around when there is not need to do so.

And just to add the concern by Ernest: yeah, theoretically you could add so many empty lines that your methods get too long/big ( see here). But well, that seems to be a limit for byte code size. As said, no empty lines in byte code, so not even a theoretical problem with that.

2

solved What’s wrong to have empty lines in Java class? [closed]