I am writing a program to manipulate large matrices and there is a memory error. I get the point that this arises as my own computer limitation but to avoid annoying error problems I am trying to try-catch an exception.
It does not work because if I defined the matrix inside the try and it gets defined, after the execution of the code gets out of the try, the matrix is no longer defined, the matrix is squared:
try {
double[][] matrix = new double[size][size];
} catch(Exception e) {
PRINT: The matrix is too big for your computer to handle.
exit-execution
}
Now if it is not too big, here the matrix, outside the try-catch, is no longer defined.
It would be the same with a matrix resize. Does any of you have a suggestion?