Why array equals () is not overridden, as in Arrays.equals ()

I understand that the equals() array acts on Object.equals() and should not be used by anyone (just use == and avoid NPE), instead they should use Arrays.equals() if they are not compared for identification.

So, why didn’t Java make the equals() method of the array overridden, as in Arrays.equals() ? This will save a lot of unexpected behavior for beginners and make it easier to use arrays (e.g. in Set ), although I can't think of any flaw. Or is there some reason that has interfered with this language?

+5
source share

Source: https://habr.com/ru/post/1272798/


All Articles