I remember from the university that there is a procedure to simply generate MOLS when n is a prime number. Basically it is about cyclic rotation of the symbols in the rows, for square k by k positions. Implementation in Java was easy:
(k * (i - 1) + (j - 1)) mod n
I remember that this was supposed to work only for n that is a prime number. And yet I found in a book that this is "guaranteed" to work also for prime powers. Which I doubt (does not work for n=4, e.g.), but I am not really that good at math and would like to understand whether the book is wrong or not.
https://books.google.de/books?id=yU-rTcurys8C&pg=PA294&dq=MOLS+construct+software+testing&hl=cs&sa=X&ved=0ahUKEwjluuz6rcrUAhVCDZoKHVuxBnIQ6AEIJzAA#v=onepage&q=MOLS%20construct%20software%20testing&f=false, page 295.
It works, but you have to work in the field $F_n$ instead of $\mathbb{Z}_n$.
Instead of indexing the rows and columns by the elements of $\mathbb{Z}_n$ you index by the elements $f_1, f_2\ldots, f_n$ of $F_n$.
Then, for each $a \in F_n^*$, construct an array $M_a$ whose $(f_i,f_j)$ entry equal to $a \cdot f_i + f_j$, where $\cdot$ and $+$ are the multiplication and addition operations in the field.
You can then check that each of these $n-1$ arrays is a Latin Square and the arrays are mutually orthogonal.
When $n$ is prime, $\mathbb{Z}_n$ is a field, $f_i = i \pmod{n}$, $a$ is one of $1,2,3, \ldots, n-1$ and the formula $a \cdot f_i + f_j$ reduces to what you are doing in your java code.