{"id":35089,"date":"2016-05-31T13:17:01","date_gmt":"2016-05-31T07:47:01","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=35089"},"modified":"2016-05-31T13:17:01","modified_gmt":"2016-05-31T07:47:01","slug":"how-to-execute-java-code-within-java-comments","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/","title":{"rendered":"How to execute Java code within Java comments"},"content":{"rendered":"<p>We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will be executed.<\/p>\n<p>[java]<br \/>\npublic class CommentTest {<br \/>\n\tpublic static void main(String[] args)<br \/>\n\t{<br \/>\n\t\t\/\/ Following line will be executed and will produce output.<br \/>\n\t\t\/\/ \\u000d System.out.println(&quot;This is the output generated from commented line&quot;);<br \/>\n\t}<br \/>\n}<br \/>\n[\/java]<\/p>\n<pre><strong>Output:\r\n<\/strong>This is the output generated from commented line\r\n<\/pre>\n<p>Why this is happening? Following is the explanation taken from <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se8\/html\/jls-3.html#jls-3.3\">\u00a0Java Language Specification &#8211; Section 3.3<\/a><\/p>\n<p>The Java programming language specifies a standard way of transforming a program written in Unicode into ASCII that changes a program into a form that can be processed by ASCII-based tools. The transformation involves converting any Unicode escapes in the source text of the program to ASCII by adding an extra <code class=\"literal\">u<\/code> &#8211; for example, <code class=\"literal\">\\u<span class=\"emphasis\"><em>xxxx<\/em><\/span><\/code>becomes <code class=\"literal\">\\uu<span class=\"emphasis\"><em>xxxx<\/em><\/span><\/code> &#8211; while simultaneously converting non-ASCII characters in the source text to Unicode escapes containing a single <code class=\"literal\">u<\/code> each.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will [&hellip;]<\/p>\n","protected":false},"author":922,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":85,"footnotes":""},"categories":[446,1994,1],"tags":[4844,3405,3406],"class_list":["post-35089","post","type-post","status-publish","format-standard","hentry","category-java","category-software-development","category-technology","tag-java","tag-java-comments","tag-unicode"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Sandeep Gupta\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"How to execute Java code within Java comments | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to execute Java code within Java comments | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#article\",\"name\":\"How to execute Java code within Java comments | TO THE NEW Blog\",\"headline\":\"How to execute Java code within Java comments\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sandeep-gupta\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2016-05-31T13:17:01+05:30\",\"dateModified\":\"2016-05-31T13:17:01+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":3,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#webpage\"},\"articleSection\":\"Java\\\/JVM, Software development, Technology, Java, Java Comments, Unicode\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#listItem\",\"name\":\"How to execute Java code within Java comments\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#listItem\",\"position\":3,\"name\":\"How to execute Java code within Java comments\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sandeep-gupta\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sandeep-gupta\\\/\",\"name\":\"Sandeep Gupta\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/e2945e1d-0be8-4468-b9d0-81471b9f234c_1566-Sandeep-Gupta-PROFILEPICTURE.jpeg\",\"width\":96,\"height\":96,\"caption\":\"Sandeep Gupta\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/\",\"name\":\"How to execute Java code within Java comments | TO THE NEW Blog\",\"description\":\"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/how-to-execute-java-code-within-java-comments\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sandeep-gupta\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/sandeep-gupta\\\/#author\"},\"datePublished\":\"2016-05-31T13:17:01+05:30\",\"dateModified\":\"2016-05-31T13:17:01+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to execute Java code within Java comments | TO THE NEW Blog","description":"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will","canonical_url":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#article","name":"How to execute Java code within Java comments | TO THE NEW Blog","headline":"How to execute Java code within Java comments","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/sandeep-gupta\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2016-05-31T13:17:01+05:30","dateModified":"2016-05-31T13:17:01+05:30","inLanguage":"en-US","commentCount":3,"mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#webpage"},"articleSection":"Java\/JVM, Software development, Technology, Java, Java Comments, Unicode"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/www.tothenew.com\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#listItem","name":"How to execute Java code within Java comments"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#listItem","position":3,"name":"How to execute Java code within Java comments","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/sandeep-gupta\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/sandeep-gupta\/","name":"Sandeep Gupta","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/e2945e1d-0be8-4468-b9d0-81471b9f234c_1566-Sandeep-Gupta-PROFILEPICTURE.jpeg","width":96,"height":96,"caption":"Sandeep Gupta"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/","name":"How to execute Java code within Java comments | TO THE NEW Blog","description":"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/sandeep-gupta\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/sandeep-gupta\/#author"},"datePublished":"2016-05-31T13:17:01+05:30","dateModified":"2016-05-31T13:17:01+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"How to execute Java code within Java comments | TO THE NEW Blog","og:description":"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will","og:url":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"How to execute Java code within Java comments | TO THE NEW Blog","twitter:description":"We all know Java comments are not visible to compiler and are not executable. But here we will see how a comment can be executed. To execute any comment we need to append a unicode as prefix to that comment and thats it. Now when you will run the code then this comment line will","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"35089","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"blog","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-29 15:01:14","updated":"2024-02-29 09:26:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to execute Java code within Java comments\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Technology","link":"https:\/\/www.tothenew.com\/blog\/category\/technology\/"},{"label":"How to execute Java code within Java comments","link":"https:\/\/www.tothenew.com\/blog\/how-to-execute-java-code-within-java-comments\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/35089","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/922"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=35089"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/35089\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=35089"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=35089"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=35089"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}