Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:06:03+00:00 2026-06-15T14:06:03+00:00

I came across the following code: public class LinePrinter { public static void main(String

  • 0

I came across the following code:

public class LinePrinter {
    public static void main(String args[]) {
      //Note: \u000A is unicode for Line Feed
      char c=0x000A;
      System.out.println(c);
    }
}

This doesn’t compile due to the Unicode replacement done.

The question is, why doesn’t the comment (//) override Unicode replacement done by the compiler? I thought the compiler should ignore the comments first before doing anything else with the code translation.

EDIT:

Not sure if the above is clear enough.

I know what happens with the above and why it errors out. My expectation is that the compiler should ignore all the commented lines before doing any translation with the code. Obviously that’s not the case here. I am expecting a rationale for this behaviour.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:06:04+00:00Added an answer on June 15, 2026 at 2:06 pm

    The specification states that a Java compiler must convert Unicode escapes to their corresponding characters before doing anything else, to allow for things like non-ASCII characters in identifiers to be protected (via native2ascii) when the code is stored or sent over a channel that is not 8-bit clean.

    This rule applies globally, in particular you can even escape comment markers using Unicode escapes. For example the following two snippets are identical:

    // Deal with opening and closing comment characters /*, etc.
    myRisquéParser.handle("/*", "*/");
    
    \u002F\u002F Deal with opening and closing comment characters /*, etc.
    myRisqu\u00E9Parser.handle("/*", "*/");
    

    If the compiler were to try and remove comments before handling Unicode escapes it would end up stripping everything from the /*, etc. to the handle("/*", "*/, leaving

    \u002F\u002F Deal with opening and closing comment characters ");
    

    which would then be unescaped to one single line comment, and then removed at the next stage of parsing. Thus generating no compiler error or warning but silently dropping a whole line of code…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I came across some Java code that had the following structure: public MyParameterizedFunction(String param1,
I just came across the following code: for(Iterator<String> iterator = stuff.iterator(); iterator.hasNext();) { ...
I was looking at the following code I came across for printing a string
I came across the following issue: I have this model public class Region {
I came across a strange phenomena upon running the following code: #include <iostream> class
I came across the following code: var collection = new Collection<string>(); I haven't seen
Should the following code give a warning? class Foo { public void Do() {
I came across the following code recently and would like to optimize it: Public
I came across following code and don't know what does having from twice mean
I came across the following code : int i; for(; scanf(%s, &i);) printf(hello); As

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.