{"id":30111,"date":"2023-01-13T08:19:58","date_gmt":"2023-01-13T02:49:58","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/"},"modified":"2023-01-13T08:19:58","modified_gmt":"2023-01-13T02:49:58","slug":"solved-what-are-the-guidelines-for-referring-to-java-methods","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/","title":{"rendered":"[Solved] What are the guidelines for referring to Java methods?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-32227939\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"32227939\" data-parentid=\"32227004\" data-score=\"1\" data-position-on-page=\"2\" data-highest-scored=\"0\" data-question-has-accepted-highest-score=\"0\" itemprop=\"suggestedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Assuming this question is referring to the difficulty of how to <em>refer<\/em> to methods when talking about Java code in a meta context. E.g.<\/p>\n<blockquote>\n<p>You should use the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/StringBuilder.html#append(java.lang.String)\"><code>StringBuilder.append()<\/code><\/a> method instead of the <code>++<\/code> operator in this context because&#8230;<\/p>\n<\/blockquote>\n<p>Now, a method we could talk about can be categorised in the following ways:<\/p>\n<ul>\n<li>static vs non-static<\/li>\n<li>has arguments vs has no arguments<\/li>\n<li>has return value vs has void type<\/li>\n<li>public vs private vs other access<\/li>\n<\/ul>\n<p>The above example is enough, in context, to be unambiguous, since there is no great overlap between methods named &#8216;append&#8217;. However, if it were lifted into some actual Java code, it could not possibly compile, for several reasons:<\/p>\n<ul>\n<li>the &#8216;append&#8217; method in question requires an argument<\/li>\n<li>it is a non-static method, and the usage above looks like a static method call.<\/li>\n<\/ul>\n<p>In addition, because it is written like a static method call, but refers to an instance method call, the reader could be confused.<\/p>\n<p>In a lot of contexts, a solution can often be found which removes all ambiguity by giving an actual code example.<\/p>\n<blockquote>\n<p>Try this approach:<\/p>\n<p><code>StringBuilder sb = new StringBuilder();<br \/>\n  sb.append(textToAppend);<\/code><\/p>\n<\/blockquote>\n<p>The problem with this is unnecessary wordiness, and it becomes a little more unwieldy and inconvenient. In addition, it loses the ability to discuss methods in a &#8216;meta&#8217; way, and there&#8217;s no obvious place to put links for reference.<\/p>\n<p>If the class of the method you are referring to is known, one way to remove all ambiguity is to give the full method signature as given in the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/overview-summary.html\">Java API Specification<\/a>, including access modifiers. E.g.<\/p>\n<blockquote>\n<p>Try using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/StringBuilder.html#append(java.lang.String)\"><code>public StringBuilder append(String str)<\/code><\/a> method of an instance of <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/StringBuilder.html\"><code>StringBuilder<\/code><\/a>. This avoids repeating the process of&#8230;<\/p>\n<\/blockquote>\n<p>This has the advantage of consistency, and of displaying all of the relevant information, but it does become more effort to type.<\/p>\n<p>If the context means there is no ambiguity, it is reasonable to omit any of the following:<\/p>\n<p><strong><em><code>public<\/code><\/em><\/strong><code>StringBuilder append(String str)<\/code><\/p>\n<p>You can omit <code>public<\/code> if the access modifier is not relevant to the discussion.<\/p>\n<p><code>public<\/code><strong><em><code>StringBuilder<\/code><\/em><\/strong><code>append(String str)<\/code><\/p>\n<p>You can omit the return type if it is obvious, or unambiguous, or not relevant to the discussion.<\/p>\n<p><code>public StringBuilder append(String<\/code><strong><em><code>str<\/code><\/em><\/strong><code>)<\/code><\/p>\n<p>You can omit parameter names if they aren&#8217;t relevant to the discussion (normally the case).<\/p>\n<p><code>public StringBuilder append<\/code><strong><em><code>(String str)<\/code><\/em><\/strong><\/p>\n<p>You can omit parameters altogether if there&#8217;s no ambiguity in the intention or they aren&#8217;t relevant.<\/p>\n<blockquote>\n<p>Try using the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/StringBuilder.html#append(java.lang.String)\"><code>append<\/code><\/a> method of an instance of <a rel=\"nofollow noopener\" target=\"_blank\" href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/StringBuilder.html\"><code>StringBuilder<\/code><\/a>. This avoids repeating the process of&#8230;<\/p>\n<\/blockquote>\n<p>This is perhaps the most unambiguous approach while avoiding unnecessary information. That said, the notation in my very first example is very convenient and often will not lead to confusion.<\/p>\n<p>In the end it&#8217;s down to a matter of taste, but avoiding ambiguity should be the most important consideration, and to that end, adopting an approach relatively in line with the Java API specification itself seems a good idea.<\/p>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\"><\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved What are the guidelines for referring to Java methods? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Assuming this question is referring to the difficulty of how to refer to methods when talking about Java code in a meta context. E.g. You should use the StringBuilder.append() method instead of the ++ operator in this context because&#8230; Now, a method we could talk about can be categorised in the following ways: static &#8230; <a title=\"[Solved] What are the guidelines for referring to Java methods?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\" aria-label=\"More on [Solved] What are the guidelines for referring to Java methods?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[323,419],"class_list":["post-30111","post","type-post","status-publish","format-standard","hentry","category-solved","tag-java","tag-methods"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] What are the guidelines for referring to Java methods? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] What are the guidelines for referring to Java methods? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Assuming this question is referring to the difficulty of how to refer to methods when talking about Java code in a meta context. E.g. You should use the StringBuilder.append() method instead of the ++ operator in this context because&#8230; Now, a method we could talk about can be categorised in the following ways: static ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2023-01-13T02:49:58+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] What are the guidelines for referring to Java methods?\",\"datePublished\":\"2023-01-13T02:49:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\"},\"wordCount\":483,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"java\",\"methods\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\",\"name\":\"[Solved] What are the guidelines for referring to Java methods? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2023-01-13T02:49:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] What are the guidelines for referring to Java methods?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] What are the guidelines for referring to Java methods? - JassWeb","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] What are the guidelines for referring to Java methods? - JassWeb","og_description":"[ad_1] Assuming this question is referring to the difficulty of how to refer to methods when talking about Java code in a meta context. E.g. You should use the StringBuilder.append() method instead of the ++ operator in this context because&#8230; Now, a method we could talk about can be categorised in the following ways: static ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/","og_site_name":"JassWeb","article_published_time":"2023-01-13T02:49:58+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] What are the guidelines for referring to Java methods?","datePublished":"2023-01-13T02:49:58+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/"},"wordCount":483,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["java","methods"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/","url":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/","name":"[Solved] What are the guidelines for referring to Java methods? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2023-01-13T02:49:58+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-what-are-the-guidelines-for-referring-to-java-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] What are the guidelines for referring to Java methods?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=30111"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/30111\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=30111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=30111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=30111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}