{"id":2564,"date":"2016-06-22T10:14:50","date_gmt":"2016-06-22T10:14:50","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=2564"},"modified":"2021-03-21T09:57:25","modified_gmt":"2021-03-21T09:57:25","slug":"why-are-comments-important-in-a-java-program","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/why-are-comments-important-in-a-java-program\/","title":{"rendered":"Why are comments important in a java program"},"content":{"rendered":"<h3>Introduction<\/h3>\n<p>Comments are readable text in the java source code. The main reason to add comments to source code is to make the code easy to understand for humans.<\/p>\n<h3>Single &amp; Multiline comments<\/h3>\n<p><strong><a href=\"https:\/\/www.testingdocs.com\/java-program-structure\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.testingdocs.com\/java-program-structure\/<\/a><\/strong><\/p>\n<h3>Readability<\/h3>\n<p>Comments help understand the code written to other developers in the team. We can add important details, code examples in the comments to a better understanding of the code logic.<\/p>\n<p>Complex programs need well-written comments in the code explaining the algorithm etc.<\/p>\n<p>&nbsp;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2566\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments.png\" alt=\"Java comments importance\" width=\"1648\" height=\"844\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments.png 1648w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments-300x154.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments-1024x524.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments-768x393.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Java-comments-1536x787.png 1536w\" sizes=\"auto, (max-width: 1648px) 100vw, 1648px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h3>Add to Java Documentation<\/h3>\n<p>Comments also add to the Project documentation HTML files. Example of generating and adding java documentation is at:<\/p>\n<p><strong><a href=\"https:\/\/www.testingdocs.com\/working-with-documentation-comments-in-java\/\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.testingdocs.com\/working-with-documentation-comments-in-java\/<\/a><\/strong><\/p>\n<h3><\/h3>\n<h3>Legal Info<\/h3>\n<p>Most application source code files have license information in the comments section. An example of a comment that has license information is:<\/p>\n<p>\/* Licensed to the Apache Software Foundation (ASF) under one or more<br \/>\n* contributor license agreements. See the NOTICE file distributed with<br \/>\n* this work for additional information regarding copyright ownership.<br \/>\n* The ASF licenses this file to You under the Apache License, Version 2.0<br \/>\n* (the &#8220;License&#8221;); you may not use this file except in compliance with<br \/>\n* the License. You may obtain a copy of the License at<br \/>\n*<br \/>\n* http:\/\/www.apache.org\/licenses\/LICENSE-2.0<br \/>\n*\/<\/p>\n<p>&nbsp;<\/p>\n<p>TO-DOs<\/p>\n<p>Code templates: we can configure auto-generation of comments in the Code templates.<\/p>\n<p>Example of To-do generated for a method body.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2639\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template.png\" alt=\"To-Do Eclipse\" width=\"1733\" height=\"1032\" title=\"\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template.png 1733w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template-300x179.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template-1024x610.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template-768x457.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/ToDo-Code-template-1536x915.png 1536w\" sizes=\"auto, (max-width: 1733px) 100vw, 1733px\" \/><\/p>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-2564\" data-postid=\"2564\" class=\"themify_builder_content themify_builder_content-2564 themify_builder tf_clear\">\n    <\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Introduction Comments are readable text in the java source code. The main reason to add comments to source code is to make the code easy to understand for humans. Single &amp; Multiline comments https:\/\/www.testingdocs.com\/java-program-structure\/ Readability Comments help understand the code written to other developers in the team. We can add important details, code examples in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-2564","post","type-post","status-publish","format-standard","hentry","category-java","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=2564"}],"version-history":[{"count":3,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2564\/revisions"}],"predecessor-version":[{"id":19846,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/2564\/revisions\/19846"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=2564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=2564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=2564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}