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. 

Related questions

0 votes
1 answer
asked May 11, 2021 in Java by sheela_singh (9.5k points)
0 votes
1 answer
0 votes
1 answer
asked Mar 31, 2021 in Java by dante07 (13.1k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...