简体   繁体   中英

Behaviors of unicode escape sequence in comments

According to "Core Java Vol. I" by Cay Horstmann:

引用

So, the below code should not work:

class Test
{
    public static void main(String[] arg2) 
    {
        // \u00A0 is a new line  
        char alpha = 'a';
        System.out.println("abc" + alpha);
    }
}

But it works. Why?

The code works because the character is a non-breaking space and not a newline character.

Most likely what has happened is that the author has made a typo and actually meant to type \ , which is a line feed character and does indeed break as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM