{"id":623,"date":"2024-01-18T15:23:49","date_gmt":"2024-01-18T15:23:49","guid":{"rendered":"https:\/\/javigomez.org\/?p=623"},"modified":"2025-09-29T20:33:34","modified_gmt":"2025-09-29T20:33:34","slug":"u06-13-arraylist-iii","status":"publish","type":"post","link":"https:\/\/javigomez.org\/index.php\/2024\/01\/18\/u06-13-arraylist-iii\/","title":{"rendered":"U06-13-ArrayList III"},"content":{"rendered":"\n<p>Introducir datos en una ArrayList de enteros hasta que se introduzca el 0.<\/p>\n\n\n\n<p>A continuaci\u00f3n, mostrar todos los datos que hay dentro con un bucle for.<\/p>\n\n\n\n<p>Por \u00faltimo, pedir un dato y decir si existe en el array o no.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package U6;\n\nimport java.util.ArrayList;\nimport java.util.Scanner;\n\npublic class A000 {\n\n\tpublic static void main(String&#91;] args) {\n\t\tScanner sc=new Scanner(System.in);\n\t\tArrayList&lt;Integer> datos = new ArrayList&lt;>();\n\t\tint a=0;\n\t\tdo {\n\t\t\tSystem.out.println(\"Introcir dato: \");\n\t\t\ta=sc.nextInt();\n\t\t\tif (a!=0)\n\t\t\t\tdatos.add(a);\n\t\t}while (a!=0);\n\t\t\n\t\tfor (int i=0;i&lt;datos.size(); i++)\n\t\t\tSystem.out.print(datos.get(i) + \" - \");\n\t\t\n\t\tSystem.out.println();\n\t\tSystem.out.println(\"Introduce dato a buscar\");\n\t\ta=sc.nextInt();\n\t\tif (datos.contains(a))\n\t\t\tSystem.out.println(\"Elemento encontrado\");\n\t\telse\n\t\t\tSystem.out.println(\"Elemento NO encontrado\");\n\t\t\n\t\t\n\n\t\t\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 U6 13 ArrayList III\" width=\"1200\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/DLpMwr_f8Ic?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>Introducir datos en una ArrayList de enteros hasta que se introduzca el 0. A continuaci\u00f3n, mostrar todos los datos que hay dentro con un bucle &hellip; <\/p>\n","protected":false},"author":1,"featured_media":618,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[20,42,93,203,309],"class_list":["post-623","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-add","tag-arraylist","tag-contains","tag-java","tag-size"],"_links":{"self":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/623","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=623"}],"version-history":[{"count":1,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/623\/revisions"}],"predecessor-version":[{"id":896,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/posts\/623\/revisions\/896"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media\/618"}],"wp:attachment":[{"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/media?parent=623"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/categories?post=623"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/javigomez.org\/index.php\/wp-json\/wp\/v2\/tags?post=623"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}