I read that you can pass an array as a parameter to a method but is it recommended?
What i mean is, is there any other way of doing it that would be more accepted?
In my case, i have 2 classes that each contains an array and i need to check if both of them are the same or are different. So i thought of creating a method in one of the class that would take an array in parameter and then compare every value of the two arrays.
I am not sure if Arrays.equals(): works since it’s an object array and not just numbers.
I found this Java Array Comparison but it seems to be more complicated than what i need to do.
1) yes that’s OK to pass arrays as parameters, there is absolutely no problem in doing so
2) Arrays.equals(Object[] a, Object[] b) can check Object arrays (you must be sure that you have the appropriate equals method on your object if you don’t want to simply test instance identity). Note that the existence of this method is the proof of 1 😉