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.

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

From Stream to Database: Processing Market Data with Spring Boot, Redis, and Flyway

rvneto - May 8

Building a Microservices Ecosystem: Stock Brokerage Simulator (My Broker B3)

rvneto - May 1

Skill-Based Sub-Agents with LangGraph4j and Spring AI

bsorrentino 1 - Apr 30
chevron_left

Related Jobs

View all jobs →

Commenters (This Week)

11 comments
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!