{"id":643,"date":"2024-02-25T12:31:57","date_gmt":"2024-02-25T12:31:57","guid":{"rendered":"https:\/\/javigomez.org\/?p=643"},"modified":"2025-09-29T20:33:34","modified_gmt":"2025-09-29T20:33:34","slug":"u08-06-clases-en-java-enumerados","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/02\/25\/u08-06-clases-en-java-enumerados\/","title":{"rendered":"U08-06-Clases en Java &#8211; Enumerados"},"content":{"rendered":"\n<p>Los enumerados en Java, tambi\u00e9n conocidos como &#8220;enums&#8221;, son un tipo de dato especial que define un conjunto de constantes. Son una herramienta \u00fatil para mejorar la legibilidad, la seguridad y el mantenimiento del c\u00f3digo.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\nenum Semana {LUNES, MARTES, MIERCOLES, JUEVES, VIERNES, SABADO,DOMINGO}\n\n\npublic class E00_00 {\n\n\tpublic static void main(String&#91;] args) {\n\t\t\n\t\tSemana s;\n\t\t\n\t\ts=Semana.VIERNES;\n\t\t\n\t\tSystem.out.println(s);\n\t\t\n\t\tString dia;\n\t\t\n\t\tScanner sc=new Scanner(System.in);\n\t\tdia=sc.next();\n\t\t\n\t\ts=Semana.valueOf(dia);\n\t\t\n\t\tSystem.out.println(\"El valor del enumerado es: \" + s);\n\t\tSystem.out.println(\"El indice es: \" + s.ordinal());\n\t\t\n\t\tSemana&#91;] ss;\n\t\t\n\t\tss=Semana.values();\n\t\t\n\t\tfor (int i=0;i&lt;ss.length;i++) {\n\t\t\tSystem.out.println(\"Cadena: \" + String.valueOf(ss&#91;i]));\n\t\t}\n\t}\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Los enumerados en Java, tambi\u00e9n conocidos como &#8220;enums&#8221;, son un tipo de dato especial que define un conjunto de constantes. Son una herramienta \u00fatil para &hellip; <\/p>\n","protected":false},"author":1,"featured_media":644,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[134,203],"class_list":["post-643","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-enumerados","tag-java"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/643","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=643"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/643\/revisions"}],"predecessor-version":[{"id":889,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/643\/revisions\/889"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/644"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=643"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=643"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=643"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}