2

Let's have a look at the following Java code.

public class Main
{
    public static void main(String[] args)
    {
        //\u000d System.out.println("It works fine.");
    }
}

In the preceding code snippet, the only line inside the main() method contains a unicode new line character, \u000d . It displays the specified message "It works fine." even though that line is commented out. How does it work?

Tiny
  • 27,221
  • 105
  • 339
  • 599
  • possible duplicate of [Why can't I use \u000D and \u000A as CR and LF in Java?](http://stackoverflow.com/questions/3866187/why-cant-i-use-u000d-and-u000a-as-cr-and-lf-in-java) – dimo414 Jul 08 '15 at 22:31

1 Answers1

6

A little-known feature of the Java language is that Unicode escape sequences are processed anywhere in source code, before any other parsing.

That's a real newline.

You can even write an entire Java program out of nothing but escape codes.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • It can even have unicode identifiers, like class БлаБла {} . I do NOT RECOMENDED using them though – Azder Jul 22 '12 at 19:13