Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Comments that will execute in Java?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 420
    Comment on it

    We know “Comments do not Execute” . Below is the code which shows “The comments that execute” in java.

    public class Testing 
    {
        public static void main(String[] args)
         {
             // the line below this gives an output
    
             // \u000d System.out.println("comment executed");
         }
    }

    Output:

    comment executed

    Explanation:

    The reason for the comments to execute is that the Java compiler parses the unicode character \u000d as a new line,  ending the comment and beginning an instance initializer therefore System.out.println("comment executed") is on line that is not commented  the unicode character \u000d put it on new line and gets transformed into:

    public class Testing 
    {
        public static void main(String[] args)
        {
            // the line below this gives an output
            // \u000d
            System.out.println("comment executed");
        }
    }

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: