Unicode escape trick

●4 ●16 ●27
calendar_today • schedule1 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
🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

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

Why Do Java Applications Become Difficult to Maintain Even When the Code Works?

Lennox - Nov 11

Is Your Java Application Becoming Too Complex for Its Own Architecture?

nate - Nov 10

How to Build Reliable Backend APIs That Work Beyond the Happy Path

Cerad - Nov 9
chevron_left
2.5k Points • 47 Badges
India
7Posts
36Comments
8Connections
Java Trainer and Evangelist

Related Jobs

View all jobs →

Commenters (This Week)

10 comments
5 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!