Use a 'nested class' here?
I have written a class called 'Matrix', which as the name implies, is an implementation of the mathematical concept of a matrix (this being a 2 dimensional array of numbers).
There is something called an 'LU decomposition' in matrix theory, that takes a matrix, and 'decomposes' it in to two other matrices, called the 'L' and the 'U' matrices.
Now, as one of the methods for the 'Matrix' class, I have written one that performs an 'LU decomposition'. Clearly, this has to return two items - the L and the U matrices.
As Java only allows methods to return one return type, then I've resorted to tagging the matrices to a List and then to return the list. But, I've thought of a better way, and that is to create a 'nested class' called 'LUdecomposition' within the Matrix class, and then to simply only have a constructor within that class, and then to have the Lmatrix and Umatrix as arguments.
The luDecomposition method would then simply return an instance of this nested class as a return type.
Would you say this is a good way to approach this? Any better suggestions?