I want to write method which will check array size and if its greater then SIZE I want to throw error, however i don't know dimensions of array.
For example:
private void checkValidSize(int[] arr){
if (arr.length > SIZE)
throw new RuntimeException(Messages.WRONG_INPUT_ERROR);
}
If I call it with 1d array it works fine but it doesn't works for 2d arrays. As I understand 2d array is array itself containing arrays so i just need method which takes any kind of array as argument and measures its length.
If i knew that all arrays implement some kind of interface like IMesurable I would just wait for IMesurable in checkValidSize.
Is there anything like that or any other option so my function will work on any kind of array?