Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the Java code I’ve:

public class Main {

    public static void main(String[] args) {

        // new Character(' \u000d System.out.println("Hello");

    }

}

The problem here is that, in the main() method I commented out the line. But still it gives me the Hello on the console. Can anyone tell me why this is not working?

1 Answer

0 votes
by (19.7k points)

In Java, the character escape code is parsed in the source code, not just String. Therefore you are able to use Unicode identifiers without Unicode encoding. 

This is the reason the \u000d in the comment is parsed as a newline, ending the comment and beginning an instance initializer.

Interested in Java? Check out this Java tutorial by Intellipaat. 

1.2k questions

2.7k answers

501 comments

693 users

Browse Categories

...