My code basically runs through an array, finds the maximum, and then locates the indices correlated with it. The issue I have is that I would like the indices in one array instead of multiple.

For example (actual output):

```
[1] [2] [3] [4]

```

Wanted output: `[1,2,3,4]`

Here is my code:

```
 int index;
    int num = myArray[0];
    for (int i = 0; i < myArray.length; i++) {
        if (num < myArray[i]) {
            num = myArray[i];
        }
    }
    for (int j = 0; j < myArray.length; j++) {
        if(num == myArray[j]){
               index = j;
               System.out.println("[" + j + "]");
        }
    }

```

I don't know how to do this without redoing all the code. Thanks.