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

13

u/__konrad May 10 '18

I think it was a hack in Java 1.0 for text editors without Unicode support. This feature should be deprecated and compiler should print a warning if used outside string/char literal.

2

u/Kered13 May 12 '18

There's a lot of characters you may want to use (usually on a strong) but you don't want to use the literal character. Like all non printing and whitespace characters and other characters that don't make any sense in a fixed width don't environment.

1

u/vytah May 13 '18

All the other escape sequences work only inside strings. I don't know any good reason to let \u to be an exception.