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

163

u/kking254 May 10 '18

Actually executing code NOT in comments.

4

u/[deleted] May 11 '18

The code was after // and before a newline so yes it was IN comments.

7

u/kking254 May 11 '18

The code was after // then after a newline so no it wasn't IN comments.

FTFY

-1

u/[deleted] May 11 '18

I don't know if you know this but // \u000d is literally 9 characters and none of them has a decimal value of 10

3

u/coladict May 11 '18

I know you don't know this, but the article explains exactly why you're wrong! You would have known if you bothered to even skim it beyond the actual code in question.

-2

u/[deleted] May 11 '18

If you can read you'd understand I am saying the code is literally in the comment. I have other comments stating why it makes zero sense to decode the above and shows they're doing it wrong

3

u/recursive May 11 '18

Java compilers follow a specification, not what reddit posters say makes sense.

0

u/[deleted] May 12 '18

I'm not saying Java is doing something other than what it does. I'm saying not only does it make no sense it's doing what it is doing poorly and wrong

2

u/recursive May 12 '18

Correctness is defined by the spec.

0

u/[deleted] May 12 '18 edited May 12 '18

If the spec said + is subtraction and * is addition noone would say it's correct. Just like noone says only allowing one null in a unique column is a good idea (One of SQL Server biggest complaints)

→ More replies (0)