Unicode escape trick

●5 ●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.

Want more #java & #unicode-escape deep dives?

Join 6,108+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

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

Unraveling the Domain-System: Boot, Singleton, and Kernel: Part 1

Hadel - Nov 29

How I Extended a Refaster Rule in Picnic's error-prone-support (and Recovered a PR GitHub Broke)

VINAYAK GOTE - Nov 29

A Tiny Regex Bug in Adyen's Java Library, and How My Fix Shipped in SDK v42.0.0

VINAYAK GOTE - Nov 29
chevron_left
2.5k Points • 48 Badges
India
7Posts
36Comments
8Connections
Java Trainer and Evangelist

Commenters (This Week)

9 comments
2 comments
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!