Unicode escape trick

posted 1 min read

A simple Unicode escape trick

Do you think the following Java code can compile correctly?

public class HelloWorld {
    public static void main(String[] args) {
// This is the first single line comment \u0009\u000a\u000c\u002f\u002a#######
# This is between two single line comments
# How is this line getting compiled?
# The lines between the two single line comments are being treated like comment, why?
# I don't think # is a comment in java.
// This is the second single line comment  \u0009\u000a\u000c #### \u002a\u002f
        System.out.println("Hello world!");
    }
}

Please comment to explain why this code compiles.

2 Comments

0 votes
0 votes

More Posts

About Identifiers in Java

Pravin - Sep 1, 2025

Unicode escape' codec can't decode bytes in position 2-3: truncated \ uxxxxxxxx escape

Jundarer - May 9

Public key retrieval is not allowed / Needs improvement

HakoneMatate - May 24

IBM Bob Turned a 30-Day Java Upgrade Into a 3-Day Sprint

Tom Smithverified - May 19

How many constructors can a class have? (Java)

ruixiao liu - May 18
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

17 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!