Well, the title is self-explanatory. I wondered this while compiling a project which has a lot of lines commented. It's a bit silly because the jar file wouldn't increase much (some bytes) but I'm curious if this could affect a program with a lot of code and comments.
Thanks
A token can be an identifier, a literal value, a reserved word, or an operator. Comments and whitespace are mostly ignored during this phase. They are only used to separate different tokens. In the next steps, there is no concept for a comment or a whitespace, so yes, they are removed while compiling.
Class files don't have comments, they are removed by the compiler.
Java source code is compiled into bytecode when we use the javac compiler. The bytecode gets saved on the disk with the file extension . class . When the program is to be run, the bytecode is converted, using the just-in-time (JIT) compiler.
Do They Affect How the Program Runs? Implementation comments in Java code are only there for humans to read. Java compilers don't care about them and when compiling the program, they just skip over them. The size and efficiency of your compiled program will not be affected by the number of comments in your source code.
No, comments normally are stripped out in any language (not just in Java). They have no representative in byte code. What stays in there, is annotated stuff and such
It would not affect the execution or performance (unless you have commented out the wrong statements :-)
But it definitely would affect readability. There is no reason to have large blocks of commented out code (in production), version control is the way to go
See this question also.Question closed.
No, documentation isn't included in the compiled class file.
The javadocs can be generated with the javadoc
program. All javadoc will be converterd to HTML.
No, this is not added.
However, you should consider to kill dead code (i.e. commented code, but also unused code). If you think that "maybe I will need that method again", simply delete the method, and if you really need this method some day, use you SCM tool (Subversion, Git, CVS or whatever) to retrieve this old code...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With