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

12

u/JerksToSistersFeet May 10 '18

Why is it u000d instead of u000a. Isn't newline 0x0a?

3

u/[deleted] May 10 '18

0x0a is CR (carriage return). Newline is 0x0d, which is LF (line feed). On unix, LF (0x0d) is the newline. On windows, you need both CR and LF (0x0a, followed by 0x0d).

25

u/JerksToSistersFeet May 10 '18

This ASCII table says the exact opposite. LF is 10, CR is 13. http://www.asciitable.com/

16

u/[deleted] May 10 '18

D'oh... you're absolutely right! I'm guessing javac must be rather liberal in what it accepts as a line terminator. I know older Macs used only CR as a line delimiter. It's a big mess.