Execute COMMENTS in #Java | Unicode

preview_player
Показать описание
Executing Comments: Many developers think comments are never executed in a program and are only used for understanding code easier. But, in fact, they are executed. #shorts

Comments are executed because of the Unicode character “\u000d”. Java compiler parses this Unicode character as a new line because Java allows using Unicode characters without encoding.

Java Program Example:
public class Main {
public static void main(String[] args)
{


}
}

Timestamps:
0:00 - Intro
0:17 - Explanation

Рекомендации по теме
Комментарии
Автор

I assume that comments in Java still do not get executed by themselves because when source files get compiled to Java bytecode, each line gets read to make the opcodes. That a newline entered as ASCII control character or escaped as a String makes javac probably believe that the comment ended. Therefore I still think that comments which are not broken up in the same line are not executed on themselves and a decompilation check could prove it.

FunLobbyDE
visit shbcf.ru