> For the complete documentation index, see [llms.txt](https://educacion.gitbook.io/programacion/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://educacion.gitbook.io/programacion/ud2-programacion-estructurada/estructuras-repetivas.md).

# Estructuras repetivas

<figure><img src="/files/Z1JxcOpEN6OM8ZvLLtGY" alt=""><figcaption></figcaption></figure>

As **estruturas iterativas** en Java, tamén coñecidas como bucles ou ciclos, son mecanismos que permiten executar repetidamente un bloque de código mentres se cumpra unha condición determinada. Estas estruturas son fundamentais para automatizar tarefas repetitivas, controlar fluxos de execución e procesar grandes volumes de datos de maneira eficiente.

Java ofrece tres tipos principais de estruturas iterativas:

* `while`: execútase mentres a condición que se especifica sexa verdadeira. Úsase **cando o número de iteracións non está determinado de antemán** e depende dunha condición que pode cambiar durante a execución.
* `do-while`<i class="fa-copy">:copy:</i>: é **similar ao `while`, pero a diferenza principal é que garante que o bloque de código se execute polo menos unha vez**, xa que a condición avalíase ao final de cada iteración.
* `for`: úsase **cando se coñece de antemán o número de iteracións que se van realizar**. Está composto por tres partes principais: a inicialización, a condición de continuación e o incremento ou decrecemento, todos definidos na cabeceira do bucle.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://educacion.gitbook.io/programacion/ud2-programacion-estructurada/estructuras-repetivas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
