> 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/exercicios-java/ud2-solucions/arrays/introduccion-arrays.md).

# Introducción Arrays

1. 98-61 - Suma o contido das posicións pares é impares
2. A chamada é arr.length, o incremento dos bucles non funciona, IndexOut of bounds

```
public static void main(String[] args){
        int [] arr = {10,20,30,40,50};
        int primeiro = arr[0];
        for (int i=0; i< arr.length-1; i+=1){
            arr[i]=arr[(i+1)%(arr.length)];
        }
        arr[arr.length - 1] = primeiro;
        for (int i=0; i<= arr.length-1;i+=1)
            System.out.println(arr[i]);
    }
```

3. Temperaturas

```java
public class Temperaturas {
    public static void main(String[] args) {
        int[] temperaturaMeses = new int[12];

        for (int i = 0; i < temperaturaMeses.length; i++) {
            temperaturaMeses[i] = (int) (Math.random() * 41); 
        }

        System.out.println("Temperaturas medias en A Coruña (ºC):");
        for (int i = 0; i < temperaturaMeses.length; i++) {
            System.out.println("Mes " + (i + 1) + ": " + temperaturaMeses[i] + "ºC");
        }
    }
}
```

4. Notas de alumnos

```java
public class NotasAlumnos {
    public static void main(String[] args) {
        double[] notasAlumnos = new double[20];

       
        for (int i = 0; i < notasAlumnos.length; i++) {
            notasAlumnos[i] = Math.round(Math.random() * 100) / 10.0; 
        }

        System.out.println("Notas dos alumnos:");
        for (int i = 0; i < notasAlumnos.length; i++) {
            System.out.println("Alumno " + (i + 1) + ": " + notasAlumnos[i]);
        }

        double suma = 0;
        double mayor = notasAlumnos[0];
        double menor = notasAlumnos[0];

        for (int i = 0; i < notasAlumnos.length; i++) {
            suma += notasAlumnos[i];
            if (nota > maior) 
                mayor = notasAlumnos[i];
            if (nota < menor) 
                menor = notasAlumnos[i];
        }

        double media = suma / notasAlumnos.length;

        System.out.printf("\nNota media: %.1f\n", media);
        System.out.printf("Nota máis alta: %.1f\n", mayor);
        System.out.printf("Nota máis baixa: %.1f\n", menor);
    }
}
```


---

# 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/exercicios-java/ud2-solucions/arrays/introduccion-arrays.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.
