{"id":551,"date":"2023-11-27T18:04:05","date_gmt":"2023-11-27T18:04:05","guid":{"rendered":"https:\/\/javigomez.org\/?p=551"},"modified":"2025-09-29T20:33:44","modified_gmt":"2025-09-29T20:33:44","slug":"u05-04-sobrecarga-de-funciones","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2023\/11\/27\/u05-04-sobrecarga-de-funciones\/","title":{"rendered":"U05-04-Sobrecarga de funciones"},"content":{"rendered":"\n<p><br>La sobrecarga de funciones (o m\u00e9todos) en Java se refiere a la capacidad de definir m\u00faltiples m\u00e9todos con el mismo nombre en una clase, pero con diferentes par\u00e1metros. La sobrecarga permite que un mismo nombre de m\u00e9todo realice diferentes acciones seg\u00fan la cantidad o tipo de argumentos que recibe.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\npublic class A000 {\n\t\n\tstatic int sumar(int d1, int d2) {\n\t\treturn d1+d2;\n\t}\n\t\n\tstatic int sumar(int d1, int d2, int d3) {\n\t\treturn d1+d2+d3;\n\t}\n\t\n\tstatic String sumar(String d1, String d2) {\n\t\treturn d1+d2;\n\t}\n\t\n\tpublic static void main(String&#91;] args) {\n\t\t\n\t\t\n\t\tSystem.out.println(\"Suma (dos datos): \" + sumar(1,3));\n\t\tSystem.out.println(\"Suma (tres datos): \" + sumar(1,3,7));\n\t\tSystem.out.println(\"Suma (dos cadenas): \" + sumar(\"Hola \", \"Javi\"));\n\t}\n}\n <\/code><\/pre>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Java U05 02 sobrecarga funciones\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/4Ni76LFk4Fc?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>La sobrecarga de funciones (o m\u00e9todos) en Java se refiere a la capacidad de definir m\u00faltiples m\u00e9todos con el mismo nombre en una clase, pero &hellip; <\/p>\n","protected":false},"author":1,"featured_media":554,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[167,203,310],"class_list":["post-551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-funciones","tag-java","tag-sobrecarga"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/comments?post=551"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions"}],"predecessor-version":[{"id":911,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/551\/revisions\/911"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/554"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}