r/programming • • May 10 '18

Java: Executing code in comments?!

http://programming.guide/java/executing-code-in-comments.html
260 Upvotes

84 comments sorted by

View all comments

Show parent comments

20

u/KnightMiner May 10 '18

Well, maybe we should say executing code no longer in comments, since it was in a comment at one time in its life

4

u/stronglikedan May 10 '18 edited May 10 '18

Since it was typed after the newline character characters, it was never in the comment. Comment slashes --> space (the comment) --> newline --> code

20

u/KnightMiner May 10 '18

Except technically it was not a newline character when it was typed, it was a collection of characters to be replaced with a newline.

1

u/stronglikedan May 10 '18

Fixed my previous comment. It was intended to represent a new line, same as pressing the enter key, so it was intended to end the comment. Therefore, the code was never part of the comment, as the author intended.