Here's an example function in Java to output a progress bar while iterating over an array using a for loop:

```
public static void iterateWithProgressBar(int[] arr) {
    int n = arr.length;
    for (int i = 0; i < n; i++) {
        // calculate progress percentage and print progress bar
        int progress = (int)Math.round((i / (double)n) * 100);
        String progressBar = "[" + "#".repeat(progress / 10) + " ".repeat(10 - (progress / 10)) + "]";

        // print current value and progress bar
        System.out.println("Current value: " + arr[i] + " " + progressBar);
    }
}
```

This function takes an integer array `arr` as input and iterates over its elements using a for loop. At each iteration, it calculates the progress percentage as `(i / n) * 100` and uses this percentage to construct a progress bar string using the `String.repeat()` method.

The progress bar string is printed along with the current value of the array element on each iteration. Note that the progress percentage is cast to an integer to round it to the nearest whole number before constructing the progress bar string.
Scrivere una funzione in Java per visualizzare una barra di avanzamento in un ciclo for iterando sull'array 'arr'.