A better way does not exist, but there are different ways for your use cases. As the size of an array does not change in Java after it has been created, the classic way is by an iteration over the indexes:
// ejemplo de arreglo
Object[] arreglo = new Object[10];
//...
for (int i = 0; i < arreglo.length; i++){
// aqui se puede referir al objeto con arreglo[i];
}
This method uses a simple loop with a primitive like index so it is not very expensive, and it is used when it is necessary to know the index together with the object of the arrangement.
Another way, if there is no importance, how many elements exist in the array or no reference to the index is needed:
for (Object o : arreglo){
// en cada iteración "o" se refiere a un objeto del arreglo para todos objetos en el arreglo
}
Both forms need few resources and we must remember that it does not make much sense in Java to over-think the optimization of code, because a tremendous intelligence was invested to optimize the execution of the bytecode in the virtual machine from the JIT-compiler (just in time).
Just remember that it is advisable in the performance context to avoid very high functions for simple cases if you want to minimize the head. The next example uses more resources, because it involves urging several extra objects, which always means using more resources at runtime and memory:
Iterator i = Arrays.asList(arreglo).iterator();
while(i.hasNext()){
// trabajar con Objeto o = i.next()
}